<thelema>
palomer: .mli for signatures, mll for lex, .mly for yacc (ocaml variants)
<palomer>
what do you guys use for your pastebin?
<thelema>
palomer: no one standard. ocaml.pastewith.us works nicely
<palomer>
do virtual function signatures have to match? meaning, if the type of f is a subtype of g, f is located in class A which is a subclass of B and B contains virtual method g, what's going to happen?
<palomer>
is a subtype of the type of g, that is
<thelema>
yes, virtual signatures have to match. ocaml doesn't do any overloading
<thelema>
and whatever casting you might want *needs* to be explicit
<palomer>
that's a bummer
<thelema>
we deal with it pretty well
<palomer>
is there a reason for this?
<palomer>
this isn't about overloading, though, it's about subtyping
<thelema>
a concrete example: f : int -> int, g : 'a -> 'a, class B = object method virtual g : 'a -> 'a end
<thelema>
class A = object method virtual f : int -> int end
<thelema>
palomer: does this notation makae sense?
<thelema>
oops, you wanted A to have a non-virtual method.
<palomer>
I meant subtype in the sense of subclass
<palomer>
that's a bummer
<palomer>
hrmph
* palomer
is off
a13x has joined #ocaml
LordMetroid has quit ["ZzZzZz"]
a13x has quit [Read error: 113 (No route to host)]
a13x has joined #ocaml
<a13x>
hi
<a13x>
anybody alive?
<hcarty>
Most likely
<a13x>
i had a question about Unix.Sockets if you don't mind
<a13x>
how can a client detect that a connection has been closed
<thelema>
reading off the end of the connection?
<a13x>
zero bytes read returned from Unix.read?
jonathanv has joined #ocaml
Cosmos95 has joined #ocaml
jonafan has quit [Read error: 110 (Connection timed out)]
<thelema>
> if the connection is terminated, a signal, with a value of SIGPIPE, is sent to the process that tried to perform a read on socket.
<thelema>
you could also get an error code (ECONNRESET, etc)
<a13x>
thanks
<jdev>
IIRC, it's only when you try to write to a closed socket/pipe that the SIGPIPE is posted and (if survived) EPIPE returned.
<thelema>
jdavis_: you may be right
<thelema>
err, jdev
<a13x>
it seems econnreset is enough
jargonjustin has joined #ocaml
<jargonjustin>
Is there a good resource resource for learning how different ocaml constructs perform? I'm particularly interested in how local functions, closures that don't escape the enclosing scope, and local functions versus methods in objects perform.
det has quit [Remote closed the connection]
aminorex has left #ocaml []
<mwc>
jargonjustin, don't know of any, but you could write microbenchmarks if you care.
<jargonjustin>
mwc: I considered it, I think profiling my app and playing with the hotspots is probably the way to go for now
<jargonjustin>
Just checking if there was any literature out there
<a13x>
funny thing, my app crashes instead of trying to catch exceptions with closed sockets
<a13x>
thanks to everyone who helped me out in the past month
<a13x>
farewell
a13x has quit ["Leaving"]
ttamttam has joined #ocaml
seafood_ has quit []
pango has quit [Remote closed the connection]
pango has joined #ocaml
seafood_ has joined #ocaml
ygrek has joined #ocaml
ygrek has quit [Remote closed the connection]
<tsuyoshi>
rwmjones: in ancient, what is the my_realloc for? it doesn't do anything
middayc has quit []
ramkrsna has quit [Read error: 110 (Connection timed out)]
seafood_ has quit []
<rwmjones>
tsuyoshi, you need to pass a realloc & free callback to 'mark', and depending on whether you want to mark data into the C heap or a heap managed by mmalloc, you pass different callbacks
<rwmjones>
tsuyoshi, so my_realloc is used when you want to mark data to the C heap
m3ga has joined #ocaml
yangsx_ has quit [Read error: 110 (Connection timed out)]
bongy has joined #ocaml
OChameau has joined #ocaml
hkBst has joined #ocaml
Yoric[DT] has joined #ocaml
<Yoric[DT]>
hi
<ziph>
Hiya.
digger has joined #ocaml
LordMetroid has joined #ocaml
rwmjones has quit ["Closed connection"]
m3ga has quit ["disappearing into the sunset"]
rwmjones has joined #ocaml
digger has quit []
dwmw2_gone is now known as dwmw2
rwmjones has quit ["Closed connection"]
rwmjones has joined #ocaml
<ikatz>
i have a design question...
<ikatz>
say i have a functorial interface to some module
lordmetroid_ has joined #ocaml
<ikatz>
and the struct i'm passing into the functor would need some values computed from stdin
<ikatz>
does that mean i'm going about this the wrong way?
<ikatz>
my first impulse is to define the module inside my main "let _ = ..." function
<ikatz>
but that syntax gets rejected
<ikatz>
i hope that explanation makes sense... but let me take another shot at it anyway
<ikatz>
i am writing code to do AI searches. it made sense to me to write a general-purpose module for the searching
<ikatz>
so the search module is a functor that takes a "problem domain" structure
<ikatz>
"problem domain" has functions like initial state, successor function, goal test, etc
<ikatz>
in the problem i am working on, the initial state and the possible actions (needed for the successor function) are read from stdin
<petchema>
functorized doesn't imply purely functional... I don't see the problem with using stdin...
<ikatz>
right... but where do i put the code that reads from standard in?
<petchema>
where you want
<ikatz>
does it go inside the functor?
<ikatz>
well..
<ikatz>
i have something like:
<ikatz>
let _ =
<ikatz>
mydata = parser.main .exer.token lexbuf in
<ikatz>
module MyProblem = struct
<ikatz>
let .... blah blah blah = mydata
<ikatz>
end
<petchema>
module ... is a definition, not an expression
<ikatz>
right
<petchema>
so it's normal it's rejected with a let ... in ...
<petchema>
s/with/within/
<ikatz>
so how would i create a module that contains function definitons derived from data gathered on stdin?
bongy has quit ["Leaving"]
<ikatz>
because the only alternative i can think of is making a module that contains the "read from stdin" function
<ikatz>
and i just want to make sure that that's the right way to do it
LordMetroid has quit [Connection timed out]
<petchema>
function parameters...
<petchema>
you can pass that read-from-stdin function as parameter, for example
seafood_ has joined #ocaml
munga has joined #ocaml
<ikatz>
does that mean i need to rewrite my functor?
<ikatz>
how would i do the technique you're talking about?
lordmetroid__ has joined #ocaml
rwmjones has quit ["Closed connection"]
<ikatz>
petchema: can you give me an example?
gaja has quit ["leaving"]
rwmjones has joined #ocaml
marmottine has joined #ocaml
lordmetroid_ has quit [Read error: 110 (Connection timed out)]
Cosmos95 has quit []
pango has quit [Remote closed the connection]
pango has joined #ocaml
Snark has joined #ocaml
lordmetroid_ has joined #ocaml
LordMetroid has joined #ocaml
lordmetroid__ has quit [Read error: 110 (Connection timed out)]
seafood_ has quit []
lordmetroid_ has quit [Connection timed out]
RobertFischer has joined #ocaml
seafood_ has joined #ocaml
ziph has quit []
Smerdyakov has quit ["Leaving"]
Smerdyakov has joined #ocaml
seafood_ has quit []
Snark has quit [Read error: 113 (No route to host)]
aminore1 has joined #ocaml
LordMetroid has quit [Read error: 110 (Connection timed out)]
LordMetroid has joined #ocaml
delamarche has joined #ocaml
LordMetroid has quit ["Leaving"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
Morphous has joined #ocaml
Morphous_ has quit [Read error: 110 (Connection timed out)]
ttamttam has left #ocaml []
evn has joined #ocaml
|Catch22| has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
ygrek has joined #ocaml
bluestorm has joined #ocaml
Snark has joined #ocaml
ita has joined #ocaml
ita has left #ocaml []
jargonjustin has joined #ocaml
jargonjustin has left #ocaml []
OChameau has quit [Read error: 113 (No route to host)]
jargonjustin has joined #ocaml
Morphous has quit [Connection timed out]
Morphous has joined #ocaml
Morphous has quit ["shutdown"]
Amorphous has joined #ocaml
dwmw2 is now known as dwmw2_gone
<palomer>
is there a good lablgtk tutorial around?
<palomer>
actually, I think I need an ocaml tutorial beforehand
<bluestorm>
palomer: records are products, variants are sums
<bluestorm>
so yes "couterpart" is a very good point of view
<bluestorm>
(actually variants can embed an product too, with type ('a, 'b) foo = Foo of 'a * 'b, but they primarily are sums)
<palomer>
is there a reason why record fields are unique?
<bluestorm>
because of type inference
<bluestorm>
if you had no unicity
<bluestorm>
let foo x = x.field
<bluestorm>
you wouldn't know "x" type
<palomer>
ahh, you want to infer the type of x
<palomer>
gotcha
<palomer>
couldn't foo have type
<palomer>
{x:'a} -> 'a
<palomer>
(sorry for the syntax)
<bluestorm>
hm
<Smerdyakov>
palomer, that's hardly a concrete suggestion, since you haven't said how to modify the type inference algorithm.
<bluestorm>
you mean {field:'a} ?
<palomer>
err, yeah
<bluestorm>
so you would like to add subtyping and the like
<palomer>
yeah
<bluestorm>
that's very near to what objects provide
<palomer>
Smerdyakov, I just want to gain more insight
<Smerdyakov>
SML has a way of doing this, which ends up being very similar to how polymorphic variant type inference is handled in OCaml.
<bluestorm>
al foo : < field : 'a; .. > -> 'a = <fun>
<palomer>
sml has subtyping between records?
<bluestorm>
urgh
<bluestorm>
# let foo x = x#field;;
<bluestorm>
val foo : < field : 'a; .. > -> 'a = <fun>
<palomer>
nice
<Smerdyakov>
No. SML type inference involves open record types as intermediate results.
<palomer>
Smerdyakov, so record fields are still unique
<Smerdyakov>
palomer, no.
<palomer>
bluestorm, are there any advantages of using records over objects?
<bluestorm>
records are simpler
<bluestorm>
you won't need subtyping most of the time
<bluestorm>
and objects can raise quite delicate typing issues (eg. rank-2 polymorphism)
<palomer>
ocaml has rank-2 polymorphism?
<bluestorm>
hm
<bluestorm>
inside records and objects, yes :-'
<palomer>
Smerdyakov, I haven't touched sml in 2 years, lemme download and fire up smlnj
<Smerdyakov>
palomer, no, I forbid it.
<palomer>
so records are a poor man's object?
<palomer>
Smerdyakov, but I want to see what sml does!
<bluestorm>
palomer: are closures poor man instances ?
<bluestorm>
i'm not sure the "poor man" thing is appropriate
<bluestorm>
if you want more (eg. subtyping) you can have
<bluestorm>
but it's more complicated, so if you don't need that, records are better
<palomer>
Smerdyakov, what's the sml syntax for the record directed foo function previously mentioned?
<palomer>
bluestorm, but records can be implemented using objects in a trivial way, right?
<Smerdyakov>
palomer, #field
<bluestorm>
i guess so
Snark has quit ["Ex-Chat"]
bluestorm has quit ["Konversation terminated!"]
<flux>
palomer, however objects cannot be pattern matched
<palomer>
ahh, there's the difference!
<flux>
I suppose if that were fixed, there would be no actual reason to use records.. bluestorm up for a camlp4 extension?-)
<palomer>
well, sml doesn't want to type foo until it knows more about it
<flux>
(I don't know how, though)
<Smerdyakov>
palomer, like I said, open record types are intermediate constituents of type inference. They all need to be resolved by the end.
<palomer>
gotcha
<flux>
match object method a = b end with | {#a = 42} -> .. let o = object method a = b end in let a = lazy o#a .. and use lazy pattern matching by yoric afterwards?