<bk_>
on the other hand, these are not realworld examples
<whee>
thomas001: I doubt you could say either is faster than the other
<whee>
they'd be comparable, I suppose
<whee>
the deciding factor in that case is the language itself, and I feel sml is a little too verbose for my tastes :)
<ita>
under what license is ocamlopt released ?
<thomas001>
structures are a bit messed up in ocaml.....
<whee>
thomas001: how so?
<whee>
ita: I think it's the Q public license
<thomas001>
whee: i haven't found a way to have 2 structure types where some element names are the same
<whee>
thomas001: are you referring to variants or modules
<Riastradh>
I think he means records.
<whee>
oh, okay
<thomas001>
sry yes records i'm use to C language...
<Riastradh>
type person = { name : string; phone_number : int; age : int }
<Riastradh>
You can -- just as long as you use qualified names --.
<Riastradh>
module People = struct
<Riastradh>
type person = ...
<Riastradh>
end
<Riastradh>
module Gizmotroids = struct
<Riastradh>
type gizmotroid = { name : string; ... }
<Riastradh>
end
<thomas001>
so it's inpossiblte within the same module?
<thomas001>
*impossible
<Riastradh>
Then use some_person.People.name and some_gizmotroids.Gizmotroid.name to get the different fields.
<thomas001>
(why is this neccessary?)
<Riastradh>
No, it's possible, but you'll have to use sub-modules.
<thomas001>
what's wrong with: type p2={x:int;y:int;};;type p3={x:int;y:int;z:int;};; within the same module?
<Riastradh>
Efficiency, I think -- with it this way, the compiler can just compile each field reference to a single memory lookup and not waste time checking what the type is.
<whee>
although I don't know about the performance of that
<Riastradh>
Classes will probably end up twenty times slower than the qualified names.
<whee>
for something like a point structure a class seems like overkill
<whee>
it'd be tempting to try to come up with a camlp4 solution to it, so the module creation is done behind the scenes
<thomas001>
hmm all method calls are virtual in ocaml?
<whee>
I believe it calls the most specific method, and coercing to a to a parent class is explicit
<whee>
hooray for typos :|
<mrvn>
thomas001: type a = { x:int; } type b = { x:int:} let c = { x=1;}
<mrvn>
thomas001: Aprt from b shadowing a nothing is wrong with it.
<mrvn>
thomas001: and yes, ocaml only has virtual methods.
<thomas001>
hmm thanks
<mrvn>
and purely virtual.
<mrvn>
thomas001: You should put p2 and p3 in different modules or use p2_x and p3_x as labels.
<whee>
mrvn: if you go and define type a = {x:int;} and then b = {x:int; y:int;}, you can't use type a
<mrvn>
whee: cause you can.
<whee>
if they're in the same module?
<mrvn>
type a = { x:int;} let make_a x = {x=x;} type b = {x:int; y:int;} let make_b x y = {x=x; y=y;}
<thomas001>
in some sml vs ocaml document i read that in sml you do not need to declare a record type and syntax looks very different...are sml records less efficient than ocaml ones?
<whee>
well, they aren't defined at the same time there :P
<thomas001>
?
<Riastradh>
thomas001, I think the efficiency is probably the same; the downside to the SML version is that you have to explicitly annotate the types.
thomas001 has quit [Read error: 60 (Operation timed out)]
Demitar has quit [Read error: 113 (No route to host)]
demitar_ is now known as Demitar
Demitar has quit ["There are bubbles in the air..."]
Demitar has joined #ocaml
palomer has joined #ocaml
<palomer>
hello, im trying to do something using functional programming but I con't find a way of doing it elegantly. im extracting two parts of a string, but I won't know the length of the first part until I extract it. any suggestions?
<Demitar>
Doing something like this? let extract_fun s = let split_position = position_fun s in (String.sub s ..., String.sub s ...);;
mrvn_ has joined #ocaml
<palomer>
erm?
<Demitar>
How do you extract the first part?
<Demitar>
Ah now I see what you're asking.
<Demitar>
You're wondering how to figure out the length of the string you need to allocate in advance, right? In that case I'd say you should go imperative and use the Buffer module, that's what it's there for.
<palomer>
hrm
<palomer>
actually, the string has N distinct parts, each part is subvided in
<palomer>
2 subparts, I won't know where the N+1 part starts until I finish
<palomer>
extracting the Nth part, and I won't know where the second sub part
<palomer>
starts until I finish extracting the first subpart
<Demitar>
So, you're essentially building a (temporary?) tree on the fly?
<palomer>
not temporary
<palomer>
I need those parts
<palomer>
but yes, its a tree
<Demitar>
What is the main problem you're facing?
<palomer>
well, extract-first-part is a function by itself
<palomer>
and I don't wish to change it
<Demitar>
I assume it returns the starting position for the second part, right?
mrvn has quit [Read error: 110 (Connection timed out)]
<palomer>
nope
<palomer>
:<
<Demitar>
So how do you know where the next part begins?
<Demitar>
base + (String.length first_part) ?
<palomer>
thats the thing
<palomer>
I don't
<palomer>
to keep it functional, I was thinking about writing a first_part_length function
<Demitar>
Umm, so how does the extract-second-part function work then? Or is that the problem (it doesn't)?
<mrvn_>
Use a stream
Smerdyakov has quit [Read error: 110 (Connection timed out)]
Smerdy has joined #ocaml
Smerdy is now known as Smerdyakov
<mrvn_>
Or allways return the offset for the next part and build the tree with references ining.
<mrvn_>
s/ining/inot the string/
<Demitar>
What's hindering you returning both the length and the resulting string? Or is that function used in a lot of other places?
<palomer>
actually
<palomer>
I think ill do that
<palomer>
thx
palomer has left #ocaml []
mattam_ is now known as mattam
Demitar has quit ["There are bubbles in the air..."]
<bk_>
hm
<bk_>
nonblocking sockets and select are a pain in the ass
<bk_>
nonblocking connect in particular
karryall has quit [leguin.freenode.net irc.freenode.net]
srv has quit [leguin.freenode.net irc.freenode.net]
foxster has quit [leguin.freenode.net irc.freenode.net]
karryall has joined #ocaml
srv has joined #ocaml
foxster has joined #ocaml
polin8 has quit [Read error: 104 (Connection reset by peer)]
<teratorn>
bk_: how's that?
<bk_>
hmm
<bk_>
no lemme investigate this a little further before i begin to moan again about something i haven't tried to figure out well enough
<bk_>
1st try didn't quite work as expected :>
<bk_>
Fatal error: exception Sys_blocked_io
<bk_>
hmmm
<bk_>
exception Sys_blocked_io
<bk_>
A special case of Sys_error raised when no I/O is possible on a non-blocking I/O channel.