pyon has quit [Quit: Dammit, f...ix yourself, Emacs.]
ztennix has quit [Ping timeout: 252 seconds]
pyon has joined #ocaml
zozozo has quit [Ping timeout: 256 seconds]
psy_ has quit [Ping timeout: 240 seconds]
Sorella has joined #ocaml
raichoo has joined #ocaml
psy_ has joined #ocaml
ztennix has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
zozozo has joined #ocaml
mort___ has quit [Quit: Leaving.]
mort___ has joined #ocaml
mort___ has left #ocaml [#ocaml]
kakadu has quit [Remote host closed the connection]
kakadu has joined #ocaml
lobo has quit [Ping timeout: 244 seconds]
lobo has joined #ocaml
psy_ has quit [Ping timeout: 246 seconds]
Anarchos has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 260 seconds]
sunnymilk has left #ocaml [#ocaml]
raichoo has quit [Ping timeout: 252 seconds]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
raichoo has joined #ocaml
ollehar has joined #ocaml
psy_ has joined #ocaml
ztennix has quit [Ping timeout: 250 seconds]
samrat has joined #ocaml
ztennix has joined #ocaml
ztennix has quit [Ping timeout: 250 seconds]
mcclurmc has joined #ocaml
ztennix has joined #ocaml
ztennix has quit [Ping timeout: 244 seconds]
ollehar has quit [Ping timeout: 244 seconds]
mcclurmc has quit [Ping timeout: 264 seconds]
ztennix has joined #ocaml
ztennix has quit [Ping timeout: 240 seconds]
mcclurmc has joined #ocaml
yomimono has joined #ocaml
MercurialAlchemi has joined #ocaml
Algebr has joined #ocaml
Haudegen has quit [Ping timeout: 260 seconds]
struktured has quit [Ping timeout: 252 seconds]
Haudegen has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
ygrek_ has joined #ocaml
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 244 seconds]
ygrek_ has quit [Ping timeout: 255 seconds]
tmtwd has joined #ocaml
ygrek_ has joined #ocaml
Algebr has quit [Read error: Connection reset by peer]
Algebr has joined #ocaml
mcclurmc has joined #ocaml
mcclurmc has quit [Ping timeout: 255 seconds]
yomimono has quit [Ping timeout: 250 seconds]
ygrek_ has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
ztennix has joined #ocaml
AlexRussia has joined #ocaml
JuggleTux has joined #ocaml
ztennix has quit [Ping timeout: 244 seconds]
ztennix has joined #ocaml
samrat has quit [Ping timeout: 260 seconds]
ztennix has quit [Ping timeout: 264 seconds]
Algebr` has joined #ocaml
Algebr has quit [Ping timeout: 256 seconds]
samrat has joined #ocaml
ztennix has joined #ocaml
darkf_ is now known as darkf
ztennix has quit [Ping timeout: 250 seconds]
samrat has quit [Ping timeout: 255 seconds]
<Algebr`>
Can I use multiple CAMLlocalN macros in the same function body
ztennix has joined #ocaml
<dsheets>
Algebr`, why not use ctypes?
<Algebr`>
Because I don't want to use an abstraction until I understand the underlying issues, (Up to a reasonable point)
<dsheets>
ok. you can still inspect the generated bindings with ctypes stub gen...
<Algebr`>
surely you would agree that reading code and writing it is very much different in terms of understanding.
<dsheets>
yeah, i also don't like to spend my time debugging unnecessary segfaults, though. to each his own
<Algebr`>
snarky
ztennix has quit [Ping timeout: 264 seconds]
<dsheets>
i really wasn't trying to be snarky... sorry :-/
<dsheets>
i think it can be valuable and interesting to delve into the internals of the run-time, too but unless i'm really interested in that i'll probably try to achieve my goals while avoiding that pit
<Algebr`>
ah, sorry, I had this stupid exchange on #macosx http://pastebin.com/0gbmRbf3 , making me overly sensitive
<dsheets>
wow that looks annoying... i hate os chans
<dsheets>
anyway, i think that one depends on how you are checking the open ports
ygrek_ has joined #ocaml
ztennix has joined #ocaml
ztennix has quit [Ping timeout: 260 seconds]
<Algebr`>
dsheets: fwiw, lldb is much nicer than gdb
ztennix has joined #ocaml
yomimono has joined #ocaml
ztennix has quit [Ping timeout: 244 seconds]
nullcatxxx_ has joined #ocaml
ztennix has joined #ocaml
ztennix has quit [Ping timeout: 246 seconds]
ollehar has quit [Ping timeout: 272 seconds]
raichoo1 has joined #ocaml
raichoo has quit [Ping timeout: 240 seconds]
grouzen has quit [Ping timeout: 246 seconds]
ztennix has joined #ocaml
Submarine has joined #ocaml
ollehar has joined #ocaml
ztennix has quit [Ping timeout: 264 seconds]
darkf has quit [Quit: Leaving]
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<adrien>
Algebr`: look at the definition of the CAML* macros
<adrien>
they're fairly straight-forward and you'll learn a lot :)
ryanartecona has joined #ocaml
Haudegen has quit [Ping timeout: 255 seconds]
thomasga has joined #ocaml
troydm has quit [Quit: What is hope? That all of your wishes and all of your dreams come true? (C) Rau Le Creuset]
troydm has joined #ocaml
f[x] has joined #ocaml
Haudegen has joined #ocaml
ygrek_ has quit [Ping timeout: 268 seconds]
<Algebr`>
adrien: is there anything special about mutable fields in records?
<Algebr`>
and the C/OCaml binding
kaepora has joined #ocaml
<ollehar>
does ocaml do string interning?
<companion_cube>
the write barrier, maybe
<companion_cube>
ollehar: no, not in general
<ollehar>
companion_cube: why not?
<kaepora>
What does "string interning" mean? *curious*
<ollehar>
kaepora: store unique strings in table, so you can do string comparison with just comparing pointers instead of each char.
<kaepora>
ollehar: Interesting, thank you
<adrien>
it doesn't
<adrien>
actually
<adrien>
hmmm
<adrien>
I'm really not sure anymore
<adrien>
Algebr`: non-optimizations :P
<flux>
ollehar, mutable strings kinda break that
<flux>
nevertheles, I don't think it's a big win in general..
<ollehar>
flux: uh? didn't ocaml just change to immutable strings??
<flux>
keyword "just"
<flux>
and the strings aren't really going to be immutable for some time
<companion_cube>
anyway, you can intern strings if you want, using Weak.Make
<flux>
there's a lot of code still using mutable strings
nullcatxxx_ has joined #ocaml
<flux>
but thanks for the reminder, I've been just modifying code that could be updated to mutable Bytes.t ;)
<flux>
this optimization is mostly ever performed to string literals, just doing it for any string instance ever would bring down the performance of code manipulating strings heavily
inr has joined #ocaml
<ollehar>
flux: really? I was just thinking about how much string interning should be applied. I'm reading the PHP source code, but can't get anything out of it. Same with Java/C#, where you can control the behaviour at runtime partly, but...
<ollehar>
there doesn't seem to be any answer to how much, when and where.
<ollehar>
*clear
<flux>
ollehar, well, for example in Java you have the method 'String.intern' to perform interning
Haudegen has quit [Ping timeout: 265 seconds]
<flux>
I think string literals are internized automatically
<ollehar>
flux: exactly. same in C#.
<ollehar>
yeah, but how about dynamic ones?
<flux>
well, what would be the point of the method if strings just got automatically interned?-)
<flux>
in other words: no, they are not
<ollehar>
flux: you think they should be? hm, you answered that already.
<flux>
I mean, in the case of Java where the strings are immutable
<flux>
you would never be able to create a non-interned string anyway. no point providing a way to re-intern it I think.
<ollehar>
flux: > you would never be able to create a non-interned string anyway
<ollehar>
what do you mean?
<flux>
ollehar, if all strings were automatically interned. but they aren't.
struktured has joined #ocaml
<ollehar>
flux: ah, yeah. but there might be some kind of mechanism that interns strings eventually, right?
<ollehar>
ach, I should maybe just ask the java folks.
<flux>
the .intern method..
f[x] has quit [Ping timeout: 244 seconds]
<ollehar>
automatically, I mean.
<flux>
but why?
<flux>
interning strings isn't free
<flux>
and the applications that benefit from it are maybe in the 1%
<mrvn>
what is interning?
Haudegen has joined #ocaml
<ollehar>
flux: don't know why. :) just wondering how the algorithm is usually applied.
<flux>
mrvn, ensuring that for each non-distinct string object is stored only once
ztennix has joined #ocaml
<ollehar>
mrvn: store unique strings in table, so you can do string comparison with just comparing pointers instead of each char.
<flux>
well, only if you know _all_ strings are interned
<ollehar>
hm, yeah.
<flux>
typically the benefit would only be in the amount of data stored
<ollehar>
well, thanks for the info.
<flux>
I think this whole string interning business is perhaps not that critical for a php compiler :)
<mrvn>
seems stupid to only do this for strings.
<flux>
well, many languages do it for string literals
<flux>
like C :)
<ollehar>
flux: but for PHP itself? array keys used all the time.
<mrvn>
flux: they may or may not. you can't assume they do
<ollehar>
hm
<flux>
mrvn, well, true, but I think it's going to be hard to find a widely used implementation that doesn't
<flux>
obviously you shouldn't depend on it
<flux>
..unless you know your environment
mcc has joined #ocaml
ztennix has quit [Ping timeout: 255 seconds]
Anarchos has joined #ocaml
<mcc>
So I am trying to learn to use polymorphic variants
<mcc>
do the constructors in polymorphic variants HAVE to be `constructors ?
<Anarchos>
yes
<mrvn>
That's what marks them as polymorphic
<mrvn>
There are also open variants
<mcc>
i want to do something very particular. i have a type a = B | C | D
<mcc>
and i want to create a function which takes an argument of type a' = C;
<mrvn>
[`C] or [< `C ]?
<mcc>
in other words, it is definitely (and surely provably) the case that a subset of the constructors are possible at a particular point in the code, but i still have to match and exclude the "wrong" constructors in that section of the code
<mcc>
I'm sorry, i am still confused about the meaning of that syntax :( my ' is not syntax just like… "a prime"
struktured has quit [Ping timeout: 250 seconds]
<mrvn>
mcc: [`C] means a type that is exactly `C. [< `C] means it can also be a subset.
ollehar has quit [Ping timeout: 240 seconds]
<mcc>
can you help me understand what you mean by "a subset"? like, a subset of a constructor?
<mrvn>
mcc: only makes sense if you have more constructors.
<mcc>
then a subset. my real-world situation is I have a type value = Float of float | String of string | TableValue of value Hashtbl | ObjectValue of value Hashtbl.
<zozozo>
mcc: well [< `A | `B ] means a type t that is either [ `A ], [ `B ] or [ `A | `B ]
<mcc>
And I have a entire section of code for fast operations on Hashtbl values, so I want to be able to only think about TableValue and ObjectValue there.
<mcc>
zozozo: comma is the tuple operator or something else?
<zozozo>
which comma ?
<mrvn>
mcc: do you have code that can take a Float or String but not TableValue?
<mcc>
mrvn: no, in that case i would unpack the float or the string and operate on that. TableValue/ObjectValue are unique within value in that they are sometimes mutated.
<mcc>
zozozo: I don't know what you mean by "[`A], [`B].
<mrvn>
mcc: he means "or"
<zozozo>
ah, i meant, either [ `A ] or [ `B] or ...
<mcc>
oh, i see. hm.
MrScout has joined #ocaml
<mrvn>
The point of "val f : [< `A | `B] as 'a -> 'a" is that if you have a (x : [`A]) then f x is also [`A], not [`A | `B].
<mcc>
do i understand correctly that both "open" and "polymorphic" variants use the ` weirdo-constructors tho?
<mrvn>
no
<mcc>
mrvn: oh! i see. okay, yes, i will never have a function that converts Table to Object or mixes the two.
<mcc>
(frankly i am trying to figure out if i can eliminate the distinction.)
<mcc>
The question rises, what do I pass into this handleObjectPair? Do I pass in the Value, and have to pay for a "match" to unpack the Value into a HashTbl? or do I pass in the HashTbl, already unpacked? But that's awkward because then I have to create a new tag (a small but regrettable memory cost I assume) and also because then I lose track of whether the
<mcc>
argument was a TableValue or an ObjectValue.
<mcc>
My solution is to do something fairly ridiculous, where I pass in a tuple of the value and also the hashtbl unpacked from the value.
ollehar has quit [Ping timeout: 250 seconds]
ryanartecona has quit [Quit: ryanartecona]
<mrvn>
mcc: why call a function at all?
<mrvn>
let currentValue = match boxKind with | PopulatingPackage v | PopulatingObject v -> ...
<mrvn>
after you decouple that canSeeOwnScope thing
<mcc>
so in this case, yes, I could do that. but this is an issue that shows up throughout my code
<mcc>
and often the reason i want a function is that I want to call the function in more than one place totally
Haudegen has quit [Ping timeout: 244 seconds]
<mrvn>
with [< `A | `B] you can restrict the types that can be passed to the function.
<mcc>
OK. So then this thing that I want definitely requires to switching to ` world?
<mrvn>
mcc: I don't see how any of that is relevant to line 225.
ryanartecona has joined #ocaml
<mrvn>
you are matching boxKind and you are matching all the constructors. So what subset do you want to restrict it to?
<mcc>
in order to create this table, value pair i must do a match, which I hide inside tableFrom.
<mcc>
But it is my expectation that tableFrom comes with a performance cost.
<mrvn>
`A won't be faster. it just type checks more.
bendiken has joined #ocaml
<mcc>
hm, ok.
<mrvn>
You would avoid the failwith because the type system wouldn't allow that case
<mcc>
but that is only a savings in terms of characters, not in terms of avoiding a branch?
<mrvn>
no. it avoids the branch. the type system prevents that case then.
<kaepora>
Um, what is an Smap?
<mcc>
i guess what i am thinking is there are many parts in the code where ocaml could prove that a particular variable is of a particular constructor, but i don't know how to express to ocaml it should do that.
<mcc>
mrvn: *thinks* why is it not faster then?
<mrvn>
[< `TableValue of x | `ObjectValue of x ] can only be called with those two cases
<mrvn>
It's still a box with tag.
Haudegen has joined #ocaml
<mrvn>
it might be marginally faster because you match all the constructors to the same result. ocaml might not even check the tag then.
<mrvn>
you have to check the cmm or asm output to make sure there
nullcatxxx_ has quit [Ping timeout: 265 seconds]
<Algebr`>
clang is complaining about "[-Wunused-variable] CAMLparam1(unit);", is it safe to ignore this?
<mrvn>
unused-variable is always save to ignore. Unless it should be used.
<mcc>
mrvn: oh, i see. but if i can collapse TableValue and ObjectValue into a single constructor, then it will maybe be faster in that case?
<mcc>
i acknowledge this may be the wrong time/way to think about optimization but this is very inner loop and also my interpreter has a known performance problem
<mcc>
i just want to understand what i am doing
<mrvn>
Algebr`: is unit supposed to be an argument of type unit? Why make that a CAMLparam?
<mrvn>
mcc: if it doesn't have a constructor then it wouldn't be boxed and the function would be a nop
<mcc>
The constructor would be `TableValue. I think I am asking whether unpacking the value from [ `TableValue of HashTbl ], when I do it, would be a faster operation than unpacking the value from [ `TableValue of HashTbl | `Q | `P of j ]
<mrvn>
it might be because with only one case you don't have to check the tag.
<mrvn>
[< `TableValue of x | `ObjectValue of x ] might already give you that. I don't know what the code generator will do there
<mcc>
OK. Thanks.
<mcc>
I should probably learn to read the ASM outputs.
<mrvn>
so make a test case, compile it and check the code.
<mrvn>
It's worth it for the type savety anyway though.
<mrvn>
any | _ -> failwith "can't happen" is a sign that your type is too loose.
<Algebr`>
mrvn: yes it is.
<Algebr`>
mrvn: because I thought you had to wrap all arguments to stubs with CAMLparam
<mrvn>
Algebr`: type unit has only ever one value (). There is no reason to ever access that from C. Often people map that to void
<mcc>
that makes sense
<mcc>
would you say my fear of using ` constructors is unfounded?
<mrvn>
foo : unit -> unit ==> void stub_foo(void)
<mrvn>
mcc: there is nothing to fear but fear itself.
<mcc>
i think i'm nervous about it because it seems like it makes certain kinds of typo errors possible where they weren't before.
<mcc>
I am very afraid of fear :(
<Algebr`>
mrvn: so then I don't need to do CAMLparam on unit arguments, but I still have to pass the unit argument?
<mrvn>
mcc: it prevents some types and allows others. It's not a magic bullet.
<mrvn>
Algebr`: yeah. ocaml will pass the unit argument but the C code would never know it is there.
<mcc>
thank you for the help
<mrvn>
although I'm not 100% sure if returning void is correct. The function could be used in a polymorphic context where the return value is used and it would be undefined there.
<Algebr`>
mrvn: just to be clear, say we have external foo: unit -> string = "bar", then the c stub is: value bar(value k) or is it value bar ()
tane has quit [Quit: Verlassend]
<mrvn>
Algebr`: I would say value bar (void)
<Algebr`>
right
<Algebr`>
thank you
<Algebr`>
mrvn: doing it the way you suggested makes the code not compile
<Algebr`>
scratch that, was my fault, I kept a CAMLreturn
<mrvn>
Algebr`: do you have any allocation between creating the string and returning it?
<mrvn>
Algebr`: you might need CAMLparam0(); CAMLlocal1(str); ... CAMLreturn(str);
<Algebr`>
I'm doing just one caml_copy_string
damason has quit [Ping timeout: 246 seconds]
<Algebr`>
hmm, dose crapping out on opam upgrade. signature mismatch. not on github so opening an issue is hassle...for lazy me.
lobo has quit [Ping timeout: 255 seconds]
lobo has joined #ocaml
Algebr` has quit [Ping timeout: 272 seconds]
Simn has quit [Read error: Connection reset by peer]
segmond has joined #ocaml
jbrown has joined #ocaml
ztennix has joined #ocaml
grouzen has joined #ocaml
ztennix has quit [Ping timeout: 244 seconds]
JuggleTux has quit [Ping timeout: 250 seconds]
grouzen has quit [Ping timeout: 246 seconds]
damason has joined #ocaml
lobo has quit [Quit: leaving]
wraithm has joined #ocaml
wraithm has quit [Client Quit]
Submarine has quit [Quit: Leaving]
Haudegen has quit [Ping timeout: 260 seconds]
rand000 has quit [Quit: leaving]
arthurb has joined #ocaml
kakadu has quit [Remote host closed the connection]
<arthurb>
what could cause the error "Unbound value =" ? I have two variables x and y with type M.t, M has an equal operator defined... but x=y or M.(x=y) both give me a compile time error of "Unbound value=" without much more detail
Haudegen has joined #ocaml
struktured has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]