<mrvn_>
bk_: Why should nonblocking connects be a pain?
<mrvn_>
bk_: You open a socket, yout set it non-blocking, you connect and you select for read.
<mrvn_>
you only have to remember that a read means the connect was done for that FD.
<mrvn_>
n8
<bk_>
it doesnt seem to be quite that simple
Smerdy has joined #ocaml
Smerdyakov has quit [Read error: 110 (Connection timed out)]
systems has joined #ocaml
Smerdy is now known as Smerdyakov
systems has quit ["Client Exiting"]
polin8 has quit ["Lost terminal"]
polin8 has joined #ocaml
bk_ has quit ["I'll be back"]
bk_ has joined #ocaml
polin8 has quit [Read error: 104 (Connection reset by peer)]
themus_ has quit [Read error: 110 (Connection timed out)]
brwill has quit ["leaving"]
brwill has joined #ocaml
jdrake has joined #ocaml
<jdrake>
why would 9.0 /. 0.0 be Inf. but 9/0 is a division by zero?
srv has quit [Remote closed the connection]
jdrake has quit ["Oops. This machine just fell asleep"]
d-bug has joined #ocaml
sdf has joined #ocaml
<sdf>
Hello
sdf is now known as KrAY
KrAY has quit ["Leaving"]
d-bug has quit ["*poff* going to work"]
Yurik has joined #ocaml
<Yurik>
re
async has joined #ocaml
<async>
does ocaml have symbols, like scheme?
<async>
tyoes
<async>
types*
Yurik has quit ["÷ÙÛÅÌ ÉÚ XChat"]
Yurik has joined #ocaml
<mattam>
aren't thet like type constructors or variant type constructors ?
klacke has joined #ocaml
srv has joined #ocaml
srv has quit [Remote closed the connection]
srv has joined #ocaml
klacke has quit [Remote closed the connection]
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
<bk_>
:\
<bk_>
i'm lost w/ my socket crap
<bk_>
omg it works
<bk_>
and my code looks like shit
<srv>
bk_: ^_^
<bk_>
:D
<bk_>
actually i know what i did wrong before, learned something again ;P
<bk_>
let inch = Unix.in_channel_of_descr socket <- this can actually run into an I/O Error (endpoint not connected bla) that i think one can't catch
<bk_>
solution: use Unix.read
<bk_>
doh
<mrvn_>
bk_: You put the socket into a select call in the "waiting for read" list and once it comes back its connected.
<mrvn_>
And why would you want an in_channel for a socket? Thats pretty useless
<mrvn_>
What happens with a non-blocking in_channel if you read too much from it anyway?
<Smerdyakov>
async, if you mean symbol types that you can somehow use to resolve OCaml variable names at runtime, then no. It's easy enough to implement an efficient symbol ADT, though.
<mrvn_>
Smerdyakov: a "typeof x" = fun 'a -> "'a" would be realy usefull though.
<Smerdyakov>
mrvn_, I generally purposely use "x" incorrectly to see its type in an error message. :P
<mrvn_>
Smerdyakov: I would need it for marshaling and unmarshaling.
<Smerdyakov>
What you really want is type classes, of course.
<mrvn_>
??
<Smerdyakov>
Do you know what type classes are in Haskell?
<mrvn_>
not realy.
<Smerdyakov>
They're principled overloading.
<bk_>
you're right mrvn, i guess that's happens when you 'steal' code snippets from other ppl
<Smerdyakov>
You define "classes" that have types and values associated with them.
<Smerdyakov>
You can then define instances of the classes for particular types.
<Smerdyakov>
In your case, you would make a class of Marshalable things, and define instances for things you want marshalled.
<Smerdyakov>
Then you can use a single function to marshal anything.
<mrvn_>
Smerdyakov: far too much overhead
<Smerdyakov>
mrvn_, how so?
<mrvn_>
Do you know how much memory and time classes take?
<Smerdyakov>
Type classes are not OCaml classes. They have no physical existence. They are just extra information for the compiler about operations on existing types.
<mrvn_>
but the resulting instances would be classes, right?
<Smerdyakov>
No
<Smerdyakov>
If you use a value associated with a type class (for instance, a function to turn a marshalable value to a byte stream) for a statically known type instance, it can be compiled to be indistinguishable from if you determined the type yourself and called the corresponding function directly.
<Smerdyakov>
If the type isn't statically known, then you can just pass an extra pointer to a table of instance-dependent values along with the value itself.
<Smerdyakov>
(The table of instance dependent values is statically allocated.)
<mrvn_>
I wrote some CPS style functions to be used as format for reading/writing. That way ocaml can typecheck the read/writes.
<Smerdyakov>
Well, type classes would still be much nicer.
<mrvn_>
probably but ocaml can't do them
<mattam_>
isn't there a composition operator in ocaml ?
mattam_ is now known as mattam
<smkl>
perhaps closest to type classes is to have functions like: print string "asd", print (string <*> string) ("asd","bsd") ...
<smkl>
mattam: nope
<smkl>
it has to be defined yourself
<smkl>
what i said is not very useful if you need several typeclasses
<mattam>
funck
<mattam>
k
<mattam>
i was starting to write function :)
smklsmkl has joined #ocaml
smkl has quit [Read error: 113 (No route to host)]
<mrvn_>
mattam: What should a composition operator do?
<mattam>
compose functions, say you have let inc x = x + 1 and let dec x = x - 1 then (inc $ dec) is equal to (fun x -> inc (dec x))
<mrvn_>
let ($) x y z = x (y z)
<mrvn_>
I use that for my cps format functions.
<mattam>
yep
<mattam>
exactly
<mrvn_>
I'm wondering whats more efficient: 1. keep a list of small strings as they are written and actually write them to a socket when possible or 2. copy the strings to a big buffer string and write it out in bigger chunks.
<mattam>
less context switches is generally better
<mattam>
but a big write can pause latency problems :)
<mattam>
cause
<mattam>
this sort of problems is simply ugly
<mrvn_>
the write is non-blocking so thats not a problem.
<mattam>
oh, nice
<mrvn_>
Thats why I need to queue the strings up for writing.
<mattam>
in this case i would suggest buffer & bigger chunks, but i don't have any authority on that
<mrvn_>
Damn, I need to mix both. I have more than 4 MB to buffer.
<mrvn_>
Too bad the Buffer module is so limited.
d-bug has joined #ocaml
d-bug has left #ocaml []
smklsmkl is now known as smkl
Xcalibor has joined #ocaml
<Xcalibor>
hi
<bk_>
hi
<mattam>
huh, didn't know this limit...
systems has joined #ocaml
systems has quit [Connection timed out]
<mrvn_>
On 32 bit cpus there is just so much space for the string size.