<ggole>
It's possible to do a reasonable job of GC even when you have 'real' (that is, C-style) arrays
<ggole>
D and Go are examples
<gour>
nimrod is also good
<ggole>
And some Lisp implementations used to allow it back in the day
<ggole>
Note that D and Go also have pointers
<ggole>
And largely for the same reason.
<ggole>
(Not sure about nimrod.)
<mrvn>
ocaml has ref too. They are just not as confusing as rust pointers.
ulfdoz has quit [Quit: deprecated]
ygrek has quit [Ping timeout: 240 seconds]
<ggole>
Refs are restricted to pointing at the beginning of a heap-allocated object. You can't point at a thing inside an array with a ref.
<mrvn>
ggole: Should the pointer be on the stack or the heap? managed or owned? choices, choices. Why can't rust infert that?
<mrvn>
ggole: ocamls memory representation prevents pointing inside a struct.
<ggole>
I know.
<ggole>
And I'm somewhat familiar with the tradeoffs involved.
<ggole>
Simpler GC vs indirection, etc.
<pippijn>
interior pointers are a challenge for a GC, yes
<ggole>
As for inference: I don't know, but it doesn't sound like something that is decidable.
<pippijn>
I still don't know a good way to make that efficient
<ggole>
You can do it if you make the interior pointer look different
<ggole>
It can basically be a base+offset pair
<ggole>
But that comes with downsides of its own
<pippijn>
ok, yes
<ggole>
Different types, or some kind of dispatch
<ggole>
Yuck to both.
ulfdoz has joined #ocaml
<pippijn>
well, I was thinking about this for a GC for C
Drup has joined #ocaml
<ggole>
pippijn: hmm?
<ggole>
Some conservative thing?
<pippijn>
no
<pippijn>
accurate
<ggole>
How do you do that for C?
<pippijn>
I don't know yet :)
<pippijn>
I didn't think about it very much
<ggole>
It seems tough
<pippijn>
sometimes I think about it for a while
<ggole>
With unions and stuff like that in the language
<ggole>
And pointer arithmetic
<pippijn>
ah
<pippijn>
no, not for real C :)
<ggole>
For a subset? I guess you could do that.
<pippijn>
a memory-safe subset
<mrvn>
ggole: In C a pointer is only valid for the the memory block allocated and may hold a value one byte beyond it (but may not be accessed then). So base+offset for pointers works fine.
<mrvn>
and unions may only read the value that was last written. Anything else is undefined behaviour. But lots of stuff does that.
<pippijn>
pointer arithmetic isn't a problem
<pippijn>
not any more of a problem than interior pointers
<mrvn>
they just change the offset
<pippijn>
pointer arithmetic change..
<pippijn>
right
<pippijn>
that :)
<ggole>
There's things like the struct hack that are actually used, too.
<ggole>
Although you could exclude that from your subset.
<mrvn>
and if offset < header_size or > base.size you segfault.
<mrvn>
ggole: struct hack?
<ggole>
Oh yeah, that would work
<ggole>
The struct hack is when you do struct foo { int len; foo storage[1]; }, malloc "too much" space and access the extra space by indexing into storage.
<mrvn>
ggole: The malloc determines the validity of the pointer, not the struct.
<mrvn>
and storage[0] is better.
<ggole>
The language allows it as a special case.
<ggole>
0 sized arrays are illegal in C.
<mrvn>
ggole: added in c99 iirc
<ousado>
yes
<def-lkb>
ggole: real developers do the same in ocaml. Just use Obj, make sure the beginning of the object as the same layout as the type you target, and reserve some space for your own data
<mrvn>
def-lkb: oh, that is evil
<Drup>
def-lkb: "real developers", yeaaah ... xD
<def-lkb>
:D
<companion_cube>
mrvn: I don't think rust is a failure
<Anarchos>
and just after they wrote 'the learning gap for ocaml is too high' ;)
<Drup>
Anarchos: did you ask them to provide ressources in ats ? :D
zpe has joined #ocaml
<gour>
besides acaml i (still) consider ada, although rust is also interesting
<Anarchos>
Drup why would i empty the ocean with a tea spoon ?
rand000 has quit [Quit: leaving]
Tamae has joined #ocaml
Kakadu has joined #ocaml
yezariaely has joined #ocaml
madroach has joined #ocaml
steshaw has quit [Ping timeout: 272 seconds]
ulfdoz has quit [Ping timeout: 272 seconds]
ggole has quit [Ping timeout: 248 seconds]
Yoric has quit [Ping timeout: 245 seconds]
<gour>
people in #rust ask me: does ocaml have linear/affine types & the regions/lifetimes that Rust has & what's ocamls stance on/support for lightweight concurrency?
ggole has joined #ocaml
<mrvn>
ggole: no lifetimes, only a generational GC
<Drup>
no, no and basically, no :)
<mrvn>
there is LWT
<Drup>
oh, concurrency, not parrallelism
<Drup>
so yeah, lightweight concurrency, you have two library with both the same sort of monadic interface
<Drup>
both are quite stable and well integrated in ocaml's landscape
<Drup>
(namely, lwt and async)
<gour>
thanks
darkf has quit [Quit: Leaving]
yacks has quit [Ping timeout: 245 seconds]
<ggole>
mrvn: sorry, think I missed part of that
<ggole>
Oh wait, logs.
* ggole
reads them
<mrvn>
ggole: yes, no, to get to the other side
<ggole>
...
yacks has joined #ocaml
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 245 seconds]
Kakadu has quit [Ping timeout: 245 seconds]
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 245 seconds]
madroach has quit [Quit: leaving]
madroach has joined #ocaml
Drup has quit [Ping timeout: 272 seconds]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 265 seconds]
ccasin has quit [Ping timeout: 245 seconds]
osnr has quit [Ping timeout: 264 seconds]
talzeus_ has quit [Read error: Connection reset by peer]
talzeus__ has joined #ocaml
rand000 has joined #ocaml
rand000_ has joined #ocaml
osnr has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
ccasin has joined #ocaml
amirmc has quit [Quit: Leaving.]
breakds has joined #ocaml
demonimin has quit [Remote host closed the connection]
ulfdoz has joined #ocaml
Neros has quit [Read error: Operation timed out]
rand000_ has quit [Remote host closed the connection]
rand000 has quit [Remote host closed the connection]
demonimin has joined #ocaml
Neros has joined #ocaml
Anarchos has quit [Read error: Operation timed out]
<j0sh>
is there some way to do stream parsing with lwt? (using the parser syntax)
zpe has joined #ocaml
ollehar has quit [Ping timeout: 240 seconds]
rand000 has joined #ocaml
caseyjames has joined #ocaml
ollehar has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
ollehar1 has joined #ocaml
ollehar has quit [Ping timeout: 272 seconds]
Anarchos has joined #ocaml
mcclurmc has joined #ocaml
zpe has quit [Ping timeout: 272 seconds]
moro_home has quit [Ping timeout: 248 seconds]
ollehar1 has quit [Ping timeout: 240 seconds]
<caseyjames>
Any one have any experience with the FFI or CTypes? I have a function pushing a struct into OCaml and one getting a string out. The object file is the ocaml so I don't know how the CTypes aspect works.
shafire has joined #ocaml
<shafire>
hi
mcclurmc has quit [Quit: Leaving.]
cdidd has quit [Remote host closed the connection]
cdidd has joined #ocaml
ollehar has joined #ocaml
moro_home has joined #ocaml
<shafire>
what do you use for unit tests and profiler?
<shafire>
OUnit for unit tests?
<yezariaely>
yes, ounit for unittests
<yezariaely>
+ bisect for testcoverage
<shafire>
is there something good for profiling and performance testing (in OUnit)?
<yezariaely>
not that I am aware of. Though, I did not do any profiling and performance testing in OCaml so far.
<yezariaely>
But there is definitely a tool
<yezariaely>
ocamlprof
<yezariaely>
I think. Comes with the compiler.
<shafire>
Okay, thank you!
<caseyjames>
Does anyone here have FFI experience?
<whitequark>
shafire: ocamlc -p is what you're probably looking for
<whitequark>
*ocamlopt -p
<whitequark>
it makes ocamlopt generate gprof-compatible binaries.
shafire_ has joined #ocaml
<shafire_>
hi
<shafire_>
thanks
shafire has quit [Disconnected by services]
shafire_ is now known as shafire
<shafire>
thanks whitequark
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 272 seconds]
ulfdoz_ is now known as ulfdoz
nikki93 has joined #ocaml
tane has joined #ocaml
nikki93 has quit [Ping timeout: 272 seconds]
isaacbw has joined #ocaml
zpe has joined #ocaml
zpe has quit [Read error: Connection reset by peer]
zpe has joined #ocaml
shafire has quit [Quit: Page closed]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
shinnya has quit [Ping timeout: 265 seconds]
iZsh has quit [Quit: Coyote finally caught me]
iZsh has joined #ocaml
iZsh has quit [Excess Flood]
zpe has quit [Ping timeout: 272 seconds]
iZsh has joined #ocaml
iZsh has quit [Excess Flood]
iZsh has joined #ocaml
<isaacbw>
haha, from Try Ocaml: "A Lisp programmer stole all our parentheses!"
<j0sh>
is there a way to "extract" a type or thunk from lwt, like 'a Lwt.t -> 'a
<j0sh>
without going through a bind, because that sort of implies that nearly everything else needs to be encapsulated in Lwt
cesar_ has joined #ocaml
cesar_ is now known as Guest86848
csakatoku has joined #ocaml
csakatoku has quit [Remote host closed the connection]
csakatoku has joined #ocaml
csakatoku has quit [Read error: Connection reset by peer]
csakatoku has joined #ocaml
DaveS has joined #ocaml
<DaveS>
are there GTK3 bindings for ocaml?
Guest86848 has quit [Remote host closed the connection]
<DaveS>
nm found the appropriate thread
<jpdeplaix>
j0sh: the only way is with Lwt_main.run (usually, in the entry point of your program)
<jpdeplaix>
this function should *NOT* be used inside a thread
<jpdeplaix>
(lwt thread)
zpe has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
<j0sh>
jpdeplaix: hm so i guess it's not possible to interleave lwt and non-lwt code?
zpe has quit [Ping timeout: 248 seconds]
ulfdoz has joined #ocaml
<j0sh>
i guess that kind of defeats the point of non-blocking concurrency
goudale has joined #ocaml
<goudale>
hi
<goudale>
anyone ever used the libcurl ocaml binding ?
ollehar has quit [Ping timeout: 265 seconds]
ollehar has joined #ocaml
<adrien>
gour: rust's interfaces change all the time
ggole has quit []
ollehar has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
nikki93 has joined #ocaml
ollehar has quit [Ping timeout: 248 seconds]
<gour>
adrien: well, that will also, hoepfully, come to an end with the 1.0 release which is not so far
ollehar has joined #ocaml
<gour>
and it's not to see some people address need of gui bindings which are not based on gtk only :-)
<gour>
s/not/nice
ulfdoz has quit [Ping timeout: 256 seconds]
ulfdoz has joined #ocaml
goudale has quit [Ping timeout: 272 seconds]
rand000 has quit [Ping timeout: 248 seconds]
rand000 has joined #ocaml
boogie has joined #ocaml
Drup has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
Drup has quit [Ping timeout: 240 seconds]
Drup has joined #ocaml
Yoric has joined #ocaml
goudale has joined #ocaml
goudale has quit [Ping timeout: 265 seconds]
ulfdoz has joined #ocaml
Drup has quit [Ping timeout: 240 seconds]
ulfdoz_ has joined #ocaml
wolfnn has joined #ocaml
ulfdoz has quit [Ping timeout: 272 seconds]
ulfdoz_ is now known as ulfdoz
<gour>
what's going on with the guys from OCamlPro? no 'highlights' for sept posted?
Neros has quit [Ping timeout: 272 seconds]
breakds has quit [Quit: Konversation terminated!]
Drup has joined #ocaml
Neros has joined #ocaml
rand000 has quit [Quit: leaving]
ahill-89 has joined #ocaml
Drup has quit [Ping timeout: 248 seconds]
watermind has quit [Read error: Connection reset by peer]
watermind has joined #ocaml
darkf has joined #ocaml
watermind has quit [Read error: Connection reset by peer]
<mfp>
j0sh: you'd normally do it the other way around, with Lwt_preemptive.detach : ('a -> 'b) -> 'a -> 'b Lwt.t to wrap blocking code
Drup has joined #ocaml
<mfp>
j0sh: there's also Lwt_preemptive.run_in_main : (unit -> 'a Lwt.t) -> 'a which is closer to what you had in mind
nikki93 has quit [Remote host closed the connection]
Drup has quit [Ping timeout: 272 seconds]
<j0sh>
mfp: ah, looks about right. thanks
cesar_ has joined #ocaml
cesar_ is now known as Guest80655
steshaw has joined #ocaml
boogie has quit [Remote host closed the connection]
tani has joined #ocaml
tane has quit [Disconnected by services]
tani is now known as tane
ulfdoz_ has joined #ocaml
Guest80655 has quit [Remote host closed the connection]
ulfdoz has quit [Ping timeout: 272 seconds]
ulfdoz_ is now known as ulfdoz
snearch has joined #ocaml
snearch has quit [Read error: Connection reset by peer]
ollehar has quit [Ping timeout: 240 seconds]
nikki93 has joined #ocaml
Drup has joined #ocaml
nikki93 has quit [Ping timeout: 256 seconds]
gour has quit [Disconnected by services]
gour_ has joined #ocaml
ollehar has joined #ocaml
gour_ has quit [Client Quit]
kamil_ has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-280704]: i've been blurred!]
cdidd has quit [Remote host closed the connection]
cdidd has joined #ocaml
ulfdoz has quit [Read error: Operation timed out]
strobegen has quit [Quit: Leaving.]
Yoric has quit [Ping timeout: 245 seconds]
<kamil_>
Hi, i am trying to wire function that checks if a list starts with given element using pattern matching, i have following code: http://pastebin.com/RLWaUcR4 but it seems, that "match" doesn't check list's head. I don't really know what this pattern matching is doing, because when i return elem from first match i got value that i passed to a function, not list's head. How can i use a function argument in match expression?
<kamil_>
or maybe it returns list's head and i've just forgot to run my program again? now i got confused...
<mrvn>
kamil_: pattern matching matches structure, not value
<mrvn>
| elem::tail -> binds the head to elem and the rest to tail. So any list that has a head and tail matches.
<mrvn>
try: | x::xs when x = elem -> true | _ -> false