<discocaml>
<mbacarella> (** [unsafe_get_some_assuming_some t i] is unsafe both because it does not bounds check
<discocaml>
<mbacarella> [i] and because it does not check whether the value at index [i] is none or some,
<discocaml>
<mbacarella> assuming that it is some. *)
<discocaml>
<mbacarella> val unsafe_get_some_assuming_some : 'a t -> int -> 'a
<discocaml>
<mbacarella> ```
<discocaml>
<mbacarella> aww yeah
<discocaml>
<MasterBuilder> what an ugly name for a function 🥲
<discocaml>
<mbacarella> it should be `val dangerous_get`
<discocaml>
<NULL> That would still initialise the array
Anarchos has quit [Quit: Vision[]: i've been blurred!]
<discocaml>
<NULL> You're filling it up with zeros, irrespective of the type
<discocaml>
<NULL> (In Base's case, not zeros but a fixed random value
<discocaml>
<NULL> (In Base's case, not zeros but a fixed random value)
<discocaml>
<geoff> `Caml.Obj.magic `x6e8ee3478e1d7449` in particular
<discocaml>
<mbacarella> oh, indeed.
<discocaml>
<NULL> In containers it is zeros (`Obj.repr ()` to be precise)
<discocaml>
<MasterBuilder> what are you doing that you can't afford to zero init the array anyway?
<discocaml>
<mbacarella> so what I'm hearing is if I write some C stub to create an array but don't initialize it I'm fine so long as I fully initialize it before the array is collected
<discocaml>
<NULL> If you go this route, the GC should never read uninitialised cells. I can't tell you how often the GC reads cells or what cells it reads however
<companion_cube>
It's unpredictable
<companion_cube>
But if it can reach the array it'll eventually traverse it all
<discocaml>
<MasterBuilder> oh wait you made them?
<discocaml>
<mbacarella> the bindings
<discocaml>
<mbacarella> yeah
<discocaml>
<MasterBuilder> oh, nice haha
tsns has quit [Remote host closed the connection]
<discocaml>
<mbacarella> re: array stuff, basically I'm trying to initialize an Array from a list. but I know the size of the list already which I'd like to give to Array.of_list, which unfortunately needs to scan the list once to get the length. additionally, it initializes the whole array to whatever the list hd was, then updates it from the tl
<discocaml>
<mbacarella> would be nice if there was a fast `Array.of_list_take ~n lst` or something
<discocaml>
<geoff> `init` also initializes the array to `(f 0)`. You could use it, or your own function doing similar though to avoid iterating the list more than once
<discocaml>
<geoff> `init` also initializes the array to `(f 0)`. You could use it, or your own function doing similar though to avoid iterating the list more than once though
<discocaml>
<geoff> woops forgot about editing and IRC 😬
<discocaml>
<MasterBuilder> pretty much everything looks weird on the IRC side, can't see quotes and the edits are just multiple messages, not ideal :/
<discocaml>
<MasterBuilder> pretty much everything looks weird on the IRC side, can't see quotes and the edits are just multiple (mostly duplicated) messages, not ideal :/
<discocaml>
<MasterBuilder> whoops, I also did it without thinking -_-
<discocaml>
<mbacarella> Oh hmm I suppose I could use a ref to the list and then in the Array.init f take the list ref hd as the value and replace update the ref with the tl
<discocaml>
<mbacarella> Oh hmm I suppose I could use a ref to the list and then in the Array.init f take the list ref hd as the value and update the ref with the tl
<discocaml>
<mbacarella> I couldn't even let myself think of this because it's so ugly
<discocaml>
<geoff> your own function where you use create then recurse over the list would be better and cleaner
<discocaml>
<geoff> `List.iteri` even
<discocaml>
<mbacarella> I'm presuming the Array.init lets me skip the cost of creating with a dummy initializer though
<discocaml>
<mbacarella> But perhaps the 3 ref operations per init f will wipe that gain out
<discocaml>
<mbacarella> I'm going to be doing like a trillion graph traversals so I'm trying to shave millis off of the basic traverse op
<discocaml>
<geoff> I think that `List.iteri` or your own `let rec` on the list is the best that you can do given that you can't avoid filling the array when it's created
<discocaml>
<mbacarella> without writing C stubs...
<discocaml>
<peval> i've needed the same for my HAMT implementation for a long time, tons of pointless initialization and copying
<discocaml>
<peval> and list buffers with Array.of_list because there's no mutable array buffers
<discocaml>
<peval> time to write some C
<discocaml>
<mbacarella> yeah god help me I think I need to write some C
alexherbo2 has quit [Remote host closed the connection]
<discocaml>
<geoff> Using a vector (even if it isn't builtin) isn't a possibility?
alexherbo2 has joined #ocaml
<discocaml>
<geoff> (instead of list, since you are writing to an array in the end anyway)
<discocaml>
<mbacarella> I've actually never come across an OCaml vector lib. What's good?
<discocaml>
<geoff> I've never used one of them, but I'm sure that @companion_cube is partial to the one in containers
<companion_cube>
The bridge kind of sucks but I'm still glad it's there
<discocaml>
<geoff> More lively than without
<discocaml>
<geoff> Is it not the same bot library that came with cats?
<companion_cube>
It's just matterbridge
chrisz has quit [Ping timeout: 246 seconds]
chrisz has joined #ocaml
motherfsck has quit [Ping timeout: 260 seconds]
motherfsck has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
motherfsck has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<discocaml>
<peval> got about 5% faster for making big trees out of arrays by adding elements (functionally) with a c stub instead of ocaml versions
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
bartholin has joined #ocaml
bartholin has quit [Quit: Leaving]
motherfsck has joined #ocaml
waleee has quit [Ping timeout: 255 seconds]
jao has quit [Ping timeout: 246 seconds]
bgs has joined #ocaml
motherfsck has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
motherfsck has joined #ocaml
Haudegen has joined #ocaml
bgs has quit [Remote host closed the connection]
Serpent7776 has joined #ocaml
szkl has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
olle has joined #ocaml
<discocaml>
<froyo> i worry that putting on ocaml heap scannable memory filled with garbage is just racing the gc not to crash and burn. possibility of random segfaults just to save a couple nanos. would there be a possibility actually?
<discocaml>
<froyo> mbacarella: You mentioned that you want array of list where the list's length is known. is `Array.make len (List.hd xs)` followed by `List.iteri (Array.unsafe_set arr) xs` really that bad?
rwmjones has quit [Ping timeout: 252 seconds]
rwmjones has joined #ocaml
<discocaml>
<peval> the gc wont run during the c stubs. it's the same as all the other stdlib array functions and small enough to be confident it works tbh.
<discocaml>
<peval> in my case like a persistent vector you need obj.magic even if you do it in ocaml
<discocaml>
<peval> it doesn't get you a lot though because c calls are slow and the compiler can't see through them so it probably isn't worth it in most cases
<discocaml>
<froyo> did you publish your persistent vector impl btw? I was planning to write a library myself, so I might just not, lol
<discocaml>
<peval> but it's pretty common to write some sort of combinatorial solver in ocaml and have my scheme or haskell version be 10x faster simply because the extra overhead of the data structures in ocaml
<discocaml>
<froyo> I can see c stubs being a win if you still initialize your data but use SIMD intrinsics to do so
<discocaml>
<froyo> i wonder if there's something specific to them that makes that not a valid thing to do though
<discocaml>
<froyo> otoh memset is probably already sped up with simd.. doesn't ocaml use that internally
<discocaml>
<peval> i don't see much downside to specializing the exact stdlib stubs for something like ```Array.append a [| x |]``` to get ```Array.push a x``` even if it's only a small gain
<discocaml>
<octachron> @hyphen Leo's opinion has been that unboxed types should be a prerequisite of this PR for few years now. It doesn't really make sense to keep a PR open when the RFCs for an eventual prerequisite PR is still a work in progress.
<discocaml>
<froyo> That's fair
bgs has joined #ocaml
darchitect has quit [Quit: WeeChat 3.7.1]
spip has joined #ocaml
bobo has quit [Ping timeout: 260 seconds]
bgs has quit [Remote host closed the connection]
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
<discocaml>
<Emile Trotignon> The main issue with this is the GC. You could probably do this with a C bindings or maybe even bytes, but then the GC would not look at what is inside, and if you put ocaml values other than ints in it they might get freed (or moved).
<discocaml>
<Emile Trotignon> You could also probably do some unsafe shenanigans to change the tags so that the GC does look inside, but then your uninitialised memory could be old freed ocaml values that would cause trouble when the GC tries to scan.
<discocaml>
<Emile Trotignon> If you do not need to store ocaml values, but just int or chars, then a C bindings would definitely work.
<discocaml>
<Emile Trotignon> Maybe `Bigarray` has some stuff in it for you as well, I am not sure
Haudegen has quit [Quit: Bin weg.]
<discocaml>
<Emile Trotignon> Maybe you could actually do what you want with a C stub, because I believe the GC does not run while C code is executed, but you would have to really sure that this is the case.
bgs has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
jao has joined #ocaml
<discocaml>
<Et7f3 (@me on reply)> Can we resisze array from c side ? Like add value then realloc
Haudegen has joined #ocaml
<discocaml>
<Emile Trotignon> yeah I guess, but editing ocaml values like a savage will have consequences on the GC side. I was talking about initialiasing with a known length, not resizing per se
<discocaml>
<Emile Trotignon> More efficient List.to_array, not Dynarray basically
motherfsck has quit [Ping timeout: 246 seconds]
azimut has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
duckie has joined #ocaml
motherfsck has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
rgrinberg has joined #ocaml
perrierjouet has quit [Quit: WeeChat 3.8]
perrierjouet has joined #ocaml
<discocaml>
<Nemo159> Hello everyone, am new to the community and actively looking forward to contribute to this community, can someone please help me where to start with
count3rmeasure has joined #ocaml
Haudegen has joined #ocaml
tsns has joined #ocaml
Serpent7776 has quit [Quit: leaving]
wingsorc has quit [Remote host closed the connection]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
count3rmeasure has quit [Ping timeout: 260 seconds]
count3rmeasure has joined #ocaml
tsns has quit [Remote host closed the connection]
count3rmeasure has quit [Ping timeout: 248 seconds]
count3rmeasure has joined #ocaml
trev has joined #ocaml
<discocaml>
<Et7f3 (@me on reply)> Welcome 🤗 what subject interest you ? What kind of contribution you are seeking ? Have you a working compiler ready to fire ?
mro has joined #ocaml
trev has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
mro has quit [Remote host closed the connection]
rgrinberg has quit [Client Quit]
mro has joined #ocaml
tsns has joined #ocaml
count3rmeasure has quit [Read error: Connection reset by peer]
Anarchos has joined #ocaml
Tuplanolla has joined #ocaml
mro has quit [Remote host closed the connection]
waleee has joined #ocaml
mro has joined #ocaml
mro has quit [Read error: Connection reset by peer]
mro has joined #ocaml
<Anarchos>
is it possible to reuse the C header parser from compcert in another ocaml program ?
bartholin has joined #ocaml
wingsorc has joined #ocaml
<Anarchos>
how to install lwt.unix through opam ?
<companion_cube>
opam install lwt
<companion_cube>
(if you have base-unix; if you don't, you're screwed anyway)
<Anarchos>
i have base.unix
<Anarchos>
\o/
cedric has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
bgs has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
tsns has quit [Remote host closed the connection]
tsns has joined #ocaml
<discocaml>
<Et7f3 (@me on reply)> > C header parser from compcert in another ocaml program
<discocaml>
<Et7f3 (@me on reply)> I don't think licence allow it
xgqt has quit [Remote host closed the connection]
xgqt has joined #ocaml
<Anarchos>
ok
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
<Anarchos>
companion_cube dune needs lwt to compile, and vice-versa
tsns has quit [Remote host closed the connection]
cedric has quit [Quit: Konversation terminated!]
cedric has joined #ocaml
troydm has quit [Ping timeout: 252 seconds]
cedric has quit [Client Quit]
fcambus has joined #ocaml
<discocaml>
<Anurag> Dune doesn’t require lwt to compile.
mro has quit [Quit: Leaving...]
bartholin has quit [Quit: Leaving]
<Anarchos>
anurag /_boot/dune.exe build @install File "otherlibs/dune-rpc-lwt/src/dune", line 4, characters 38-46: 4 | (libraries result csexp dune_rpc lwt lwt.unix unix) ^^^^^^^^ Error: Library "lwt.unix" not found.
azimut has quit [Ping timeout: 255 seconds]
azimut_ has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
manicennui has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]