<pattern_>
the only differences are on lines 1 and 3, where the "s" argument is placed
<pattern_>
why would the "s" argument's placement matter? it is "count" that is being incremented
<mrvn>
hey, soon we have TCPA then they can't copy the film even if its on dvd.
<mrvn>
ups
<whee>
pattern: I'm guessing the one that doesn't work does so because the inner function is only being evaluated/bound/something once, and calling it again just gets you the previous value because the arguments to it never change
<whee>
so it's assumed to have no side effects and just doesn't get reevaluated
<whee>
I don't know D:
<pattern_>
i don't understand
<pattern_>
why would the inner function only be evaluated once in one version and not the other?
<pattern_>
why would it be assumed to have no sideffects?
<pattern_>
and why wouldn't "let count = ref ( -1 )" not be re-evaluated every time, anyway?
<pattern_>
thisa makesa no sensa
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
<mrvn>
pattern_: why should it? Whats there to evaluate?
<mrvn>
Nothing is ever re-evaluated. Some thing can be applied.
<pattern_>
"let count = ref ( -1 )" is clearly evaluated the first time the function is called
<pattern_>
why shouldn't it be evaluted every time?
<mrvn>
once and only once. Everything is only evaluated once.
<pattern_>
so you're saying that the expression "let count = ref ( -1 )" is evaluted once the first time gensym is called and then the result of that evaluation is used in all subsequent calls, instead of being re-evaluated?
<pattern_>
if that is the case, then why does one of these versions not work? why is does it's "count" reference seemingly get reset every time i run it?
<mrvn>
Maybe because you evaluate the code due to an application.
<mrvn>
yep. the first one evaulates the ref once when gensym is evaluated, the second one evaulates the ref with every application of s.
<pattern_>
but why?
<mrvn>
Because a function can only be evaluated when something is applied to it.
<mrvn>
pattern_: Otherwise how would you create any local variables?
<pattern_>
well, gensym is evaluated in both versions, and "let count" is evaluated once in one
<mrvn>
pattern_: the first has gensym as a value, the second as a function (which is a value too)
<pattern_>
so the value gensym only gets evaluated once
<pattern_>
and the function gensym gets evaluated every time?
<mrvn>
allways.
<pattern_>
makes sense
<pattern_>
thanks, mrvn
<mrvn>
gensym is evaulated once in both cases. But you can applay something to a function causing it to evaluate.
<pattern_>
right
<pattern_>
i see the distinction now
<mrvn>
good, now youve got it, hopefully.
<pattern_>
yep :)
mattam has joined #ocaml
jesi has joined #ocaml
jesi is now known as sproctor
<sproctor>
hello
<pattern_>
hi, sproctor
<sproctor>
I was reading the server example from the ocaml book and there was a part that confused me.
<sproctor>
the o'reilly one. anyway, they fork, then in the parent they wait for the child to die, in the child they fork again and exit the original, and the second child does some loop.
<sproctor>
I was wondering what the point of waiting for the first child to die was, and if there was some reason they don't do the loop in the first child.
<sproctor>
any idea?
sproctor has quit ["Client Exiting"]
<mellum>
Avoiding zombies?
docelic|sleepo is now known as docelic|away
xtrm has joined #ocaml
avn has joined #ocaml
avn has left #ocaml []
avn has joined #ocaml
karryall has joined #ocaml
smkl has quit [brunner.freenode.net irc.freenode.net]
karryall has quit [brunner.freenode.net irc.freenode.net]
TrOn has quit [brunner.freenode.net irc.freenode.net]
mrvn has quit [brunner.freenode.net irc.freenode.net]
Krystof has quit [brunner.freenode.net irc.freenode.net]
cm has quit [brunner.freenode.net irc.freenode.net]
liyang has quit [brunner.freenode.net irc.freenode.net]
mellum has quit [brunner.freenode.net irc.freenode.net]
lam_ has quit [brunner.freenode.net irc.freenode.net]
emu has quit [brunner.freenode.net irc.freenode.net]
whee has quit [brunner.freenode.net irc.freenode.net]
gl has quit [brunner.freenode.net irc.freenode.net]
skylan has quit [brunner.freenode.net irc.freenode.net]
docelic|away has quit [brunner.freenode.net irc.freenode.net]
xtrm has quit [brunner.freenode.net irc.freenode.net]
mattam has quit [brunner.freenode.net irc.freenode.net]
polin8 has quit [brunner.freenode.net irc.freenode.net]
Riastradh has quit [brunner.freenode.net irc.freenode.net]
asqui has quit [brunner.freenode.net irc.freenode.net]
pattern_ has quit [brunner.freenode.net irc.freenode.net]
karryall has joined #ocaml
TrOn has joined #ocaml
mrvn has joined #ocaml
docelic|away has joined #ocaml
skylan has joined #ocaml
mellum has joined #ocaml
liyang has joined #ocaml
whee has joined #ocaml
gl has joined #ocaml
lam_ has joined #ocaml
cm has joined #ocaml
Krystof has joined #ocaml
emu has joined #ocaml
xtrm has joined #ocaml
mattam has joined #ocaml
Riastradh has joined #ocaml
polin8 has joined #ocaml
asqui has joined #ocaml
pattern_ has joined #ocaml
asqui has quit [Excess Flood]
asqui has joined #ocaml
smkl has joined #ocaml
docelic|away has quit ["Client Exiting"]
docelic has joined #ocaml
Kinners has joined #ocaml
avn has quit [Read error: 110 (Connection timed out)]
Kinners has left #ocaml []
avn has joined #ocaml
Smerdyakov has quit []
avn has quit [Read error: 110 (Connection timed out)]
avn has joined #ocaml
avn has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
docelic is now known as docelic|away
avn has joined #ocaml
TachYon26 has joined #ocaml
avn has quit [Read error: 110 (Connection timed out)]
<mellum>
Does Ocaml ever return heap memory to the OS?
<smkl>
probably when compacting
karryall has quit ["bye"]
mellum has quit [Read error: 110 (Connection timed out)]
mellum has joined #ocaml
TachYon26 has quit [Read error: 60 (Operation timed out)]
docelic|away is now known as docelic
TachYon has joined #ocaml
TachYon has quit [Remote closed the connection]
Smerdyakov has quit []
systems has joined #ocaml
foxster has joined #ocaml
systems has left #ocaml []
Smerdyakov has joined #ocaml
stepcut has joined #ocaml
<stepcut>
I don't suppose there is a way to make infix data constructors?
<stepcut>
type ThenElse 'a = 'a :> 'a
<stepcut>
without using camlp4 :)
<Smerdyakov>
There is in SML.
<stepcut>
yeah, there is in Haskell too, but all my code is in O'Caml :(
<Smerdyakov>
So the SML version is: infix myOp; datatype 'a ThenElse = myOp of 'a * 'a;
<Smerdyakov>
Did you try things similar to that?
<stepcut>
ocaml doesn't seem to have an 'infix' command
<Smerdyakov>
Did you try: type ThenElse 'a = :> of 'a * 'a
<stepcut>
yeah, but I can't use the :> in infix, so it gets hard to read
<stepcut>
I am trying to does something like: predicate ?> (if true) :> (if false)
<mrvn>
ocaml just looks at the first char of the operator.
<mrvn>
# let (+++) a b = a + b;;
<mrvn>
val ( +++ ) : int -> int -> int = <fun>
<mrvn>
# 1 +++ 2;;
<mrvn>
- : int = 3
<stepcut>
so I can can them together: p1 ?> do something :> p2 ?> do something :> p3 ?> .....
<mellum>
stepcut: are you reinventing if-then-else?
<stepcut>
mellum: yes, but for gluing together combinator filters
<mellum>
stepcut: well, I don't see why you need an infix operator there
<stepcut>
mellum: readability mostly
<mellum>
Heh, that would be a reason *against* it IMHO :)
<mellum>
And you'd loose the shortcut semantics.
<stepcut>
shortcut semantics?
<mellum>
if a then b else c will not calculate c if a is true. my_if_then_else a b c would.
<stepcut>
mrvn: actually, it looks at all the characters of the operator, so you can only use a very limited set of symbols in infix operator names, and you can't change their precedence...
<stepcut>
mellum: yes, but in this case, I can just use a normal if-then-else
* stepcut
thinks for a second
<stepcut>
in: p ?> f :> g, p,f, and g, are functions ('a -> 'a list). Basically it does something like this:
<stepcut>
let my_if_then_else p f g v = let p_result = (p v) in if (p_result = []) then (f []) else (List.map g p_result)
<stepcut>
but not quite...
<stepcut>
hrm, actually, that is wrong :)
<stepcut>
let my_if_then_else p f g v = if (p v) = [] then (f v) else (List.map g v)
<stepcut>
oh well, the infix handle in o'caml ain't gonna change this week
<stepcut>
I just wanted to be sure that I didn't miss something :)
<whee>
you could add infix operators easily using camlp4
<whee>
and do it 'correctly'
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
<stepcut>
whee: I plan on learning camlp4 in May -- I, unfortunately, have some tight deadlines for now.
stepcut has quit []
docelic is now known as docelic|sleepo
TimFreeman has joined #ocaml
mattam_ is now known as mattam
clam has joined #ocaml
TachYon has joined #ocaml
foxster has quit [Read error: 110 (Connection timed out)]
polin8 has quit [Read error: 54 (Connection reset by peer)]
polin8 has joined #ocaml
TachYon has quit [Remote closed the connection]
clam has quit [Read error: 110 (Connection timed out)]
Kinners has joined #ocaml
Kinners has left #ocaml []
TimFreeman has left #ocaml []
mrvn_ has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]