Yurik changed the topic of #ocaml to: http://icfpcontest.cse.ogi.edu/ -- OCaml wins | http://www.ocaml.org/ | http://caml.inria.fr/oreilly-book/ | http://icfp2002.cs.brown.edu/ | SWIG now supports OCaml| Early releases of OCamlBDB and OCamlGettext are available
<mrvn_> Thats what we have ocamlp4 for :)
<emu> no
<emu> ocamlp4 is closer to scheme's system
<mellum> Hm, I don't remember missing anything in Scheme macros. But I don't really know Lisp
<whee> camlp4, not ocamlp4 :P
<emu> it's separate from the language
<Riastradh> emu, syntax-rules is only used by weirdos who refuse to do anything non-R5RS; syntax-case is what most people who need more powerful macros use.
<emu> with Lisp macros, you use Lisp to rewrite Lisp code
<mrvn_> its much more than a preprocessor like cpp. :)
<emu> Riastradh: oh sure, you can always go outside of R5RS =)
<emu> people like manual serrano have done plenty of practical work
<Riastradh> syntax-case is arguably better than defmacro, anyways.
<emu> hygenic macros are a waste of time
<Riastradh> Why?
<mrvn_> Can you implement strict typechecking with lisp makros?
<Riastradh> Probably not, but that's because type checking is a compiler thing, not a macro thing.
<emu> because you can get the same effect with procedural macros, and the whole issue is only an issue in a Lisp-1 like Scheme
<Riastradh> Macros manipulate s-expressions, and only s-expressions.
<Riastradh> emu, uh, syntax-case macros -ARE- procedural macros.
lament is now known as jesus
jesus is now known as lament
<emu> afaik scheme does not have procedural macros
* Riastradh points to what he said above.
<emu> syntax-case is not in Scheme
<emu> is what you said
<Riastradh> <Riastradh> emu, syntax-rules is only used by weirdos who refuse to do anything non-R5RS; syntax-case is what most people who need more powerful macros use.
<emu> once you step outside of R5RS though you're not talking Scheme anymore
<Riastradh> Would you say that Caml and SML are MLs?
<emu> is there an ML standard?
<mellum> emu: SML == Standard ML?
<Riastradh> emu, to be technical, R5RS isn't the Scheme standard either.
<emu> mellum: so is ML SML =)
<Riastradh> IEEE 1178 or something is the official standard.
<emu> yes, it follows the previous revision, I think?
<Riastradh> Yet you claim that 'R5RS is Scheme.'
<mellum> emu: I don't know whether it's official or something
<emu> so R4RS =)
systems has joined #ocaml
<Riastradh> R4RS isn't the IEEE standard, either.
<Smerdyakov> Standard ML is pretty damned official, with the inventors of the language's names on it :P
<emu> so is ocaml an SML?
<emu> =)
<systems> ocaml is called to be stricktly typed right!!!
<emu> oro?
<systems> oro ???
<emu> my thoughts precisely
<systems> hehe
<Riastradh> systems, sentences of that wording are generally thought to be questions, and as such are suffixed with question marks.
<Smerdyakov> systems, but the answer is probably yes???
<whee> haha?
<emu> but what tense is he speaking in?
<Riastradh> You see the confusion it causes when it isn't a question mark\\\
<emu> is called to be
<systems> i read in a introduction to ocaml tutorial thing that it is, but i also know that there is no common consent on what strickly type, static typed , strong or weak typed mean!!!
<systems> so i am askin, is there like a consent that ocaml is strickly typed?
<emu> strictly typed means you cannot cut and paste with the mouse
<emu> strongly typed means you hit the keyboard really hard
<Riastradh> i.e., you have to type it with a keyboard.
<emu> statically typed means you cannot move it once you type it
<Riastradh> Weakly typed means that the keyboard has to be really sensitive, because you have to tap it very lightly.
<systems> the tutorial definition of stricly typed is that an expression return only one type, in ocaml most things are expression
<Riastradh> Dynamic typing means that you have to move your fingers with the keyboard.
<Smerdyakov> Pachidermically typed means that you type it with an elephant.
<Riastradh> Very few languages are pachidermically typed.
<emu> there is a language called elephant, i htink
<Riastradh> Icthyically typed means you type with dead fish. Most users of icthyically typed languages have to replace their computers daily.
<sproctor> I was wondering why no one would touch my keyboard...
<systems> there is a language called self, i read somewhere, that a java vm was writen in self, so i thought they mean writen in java!!!
<Riastradh> No, the Java VM is written in SNOBOL.
<sproctor> someone kill me... quick.
<emu> systems: no, they wrote it in Selfish
* Riastradh stabs sproctor.
* sproctor dies.
<Riastradh> Happy now?
<systems> true there is a lang called self, its very weird and different
<emu> indeed
<Riastradh> The Self compiler is written in INTERCAL, by the way.
<systems> not in self? very weird
<Riastradh> Whose compiler is written in Malbolge.
<Riastradh> And you don't want to go anywhere near Malbolge.
* sproctor hopes to never run across any of these langauges again.
<emu> and it's the only program written in Malbolge
<Smerdyakov> OK, Riastradh. I would hope that we can keep the language fetishisms out of this channel. =P
<Riastradh> It is physically repulsive; you have to hold your nose and close your eyes, and type with thick rubber gloves.
<emu> someone wrote hello world in malbolge
<Riastradh> It looks like stuff found generally only in /dev/urandom.
<emu> and /usr/lib/perl
<Riastradh> Worse than that.
<systems> perl, i read an intro to perl, perl is very intimidating with so many special constructs, i wonder how it became so popular
<emu> drugs
<Riastradh> Just like how C++ became so popular.
<Riastradh> So let that be a lesson to you: never use drugs, because if you do Perl will seem inviting and clean.
<systems> hehe
<emu> Dare: to keep kids off Perl
<systems> I really thought that there must be something nice in Perl, after few visit to perlmonks.org , but I guess ppl just wont let go of the things in which they invested time to learn
<emu> it's all about curly-brace fetish
<Riastradh> Indeeed.
<Riastradh> And let no one tell you that 'indeeed' is spelled with two 'e's.
<systems> like for avg-want-2-learn-how-to-program guy, popular lang seem the way to go, c++ is popular, so he learns it, after a year or so, he been around he know c++ is not that good, but dude i already learned so much c++, i must make use of it
<emu> indeed
<Riastradh> 'Indeed' is spelled with two 'e's, but not 'indeeed.'
<emu> indeed, but not intruth?
<Riastradh> Quite.
<sproctor> so... ummm, not to interupt the arguing over languages..
<emu> I think we've moved on to the spelling of 'indeeed'
<sproctor> how does Unix.accept work? it waits for a connection then returns?
<emu> I say it has 3 'e's
<Riastradh> Je ne sais pas!
<sproctor> ok, then not to interupt the spelling of 'indeed' and permutations, but...
<Riastradh> Je n'en ai pas utilise.
Kinners has joined #ocaml
<whee> I vote for e number of e's. somewhere around 2.7182818285.
<emu> e^e
<Riastradh> Note that that might round to 2 or 3, if you used the arguably best rounding system there is.
<sproctor> I'm trying to get the server example working from the oreilly book (still), but it's not accepting connections.
<systems> french cool
<Riastradh> Il n'est pas francais! Il est 'franglais.'
<emu> is that like engrish?
<sproctor> oh!
<sproctor> it was binding to the wrong IP address...
<sproctor> wow, that wasted a lot of time.
<Riastradh> Quite.
<emu> and now for something completely different
* Riastradh declares war on #php.
<systems> hehehe
* systems thinks war is not the answer
<emu> right
<systems> we should send weapons inspectors instead
<Riastradh> Against #php it is.
<emu> it's the imperative!
<Riastradh> But, systems, PHP is open source and all the documentation is available and stuff.
<systems> get them rid of all there weapons......then declae war
<emu> they're obviously a bunch of commies
<systems> cause the inspectors were not happy !!! and we feel the obligation toward the global community to be safe
<systems> the docs were not clear enough!!!
<Riastradh> Yes, but the source is still available.
<systems> they keep changing features without updating the docs
<systems> yep we send inspectors the scrute the source for weapons
<systems> s/the/to
<systems> and after we make sure they dont have any, we dalcare war >:)
<Riastradh> After that we'll dalcare war, but right now we have to declare it.
<systems> ...okay you theaten to declare, me request more inspection...
<systems> when am sure it's safe, i will let you go and beat the shit outta them
<mrvn_> spoctor: allways bind against Inet.addr_any unless you want to be more strict.
* mrvn_ says "die if !dead" to #perl
<sproctor> lol
<Riastradh> #php first. It's got fewer weapons.
<Riastradh> Perl even has closures, so we should avoid them until we've gotten rid of their other potential allies.
<mrvn_> They would all go and make perl stronger.
<Riastradh> Right, so we need to eliminate them first.
<docelic> perl needs no alllies, all potential allies together are 5% worth of perl itself ;)
<sproctor> mrvn_: thanks. this example code sucks.
<systems> then #python, they make fun of ocaml cause python is dynamic when ocaml os strict
<Riastradh> Perl programmers are too loyal (or is that stubborn?) to defend PHP.
<mrvn_> No, kill perl first and then they have noone to turn to.
<Riastradh> Maybe we should attack them all at once.
<mrvn_> List.iter destroy non_ocaml_langugages
<Riastradh> After all, neither Perl nor PHP to my knowledge have multithreading support, but OCaml does, so we could be attacking them all at once at no extra cost of resources.
<Riastradh> Ack, what about other functional languages?
<mrvn_> lt rec war = function [] -> "We won" | l -> List.iter destroy l; war (get_non_ocaml_langugages ()); war (get_non_ocaml_langugages ())
<Riastradh> Surely you don't want to destroy the Lambda-Calulus, do you!?
<systems> lisp will self destroy itself
<mrvn_> Riastradh: sure.
<systems> miranda does even have a compiler
<mrvn_> ~C++ :)
<mrvn_> ~C++() :)
<Riastradh> ?
<systems> haskell, hmmm...maybe we should allie with haskell
<mrvn_> no allies, WORD DOMINATION
<Smerdyakov> systems, all the cool people here are already in #haskell
<mrvn_> +L
<Smerdyakov> and #sml !!
<Riastradh> Yes, let's dominate the word!!
<mrvn_> Smerdyakov: *slap*
<systems> ocaml is the coolest of the cool
<Riastradh> But it doesn't even have continuations.
<mrvn_> Riastradh: it does, via fork for example :)
<mrvn_> Maybe one of the language extensions of typesave continuations makes it into ocaml.-
<Riastradh> Hrm? How do you use fork to emulate continuations?
<mrvn_> google: ocaml callcc fork, first link
<mrvn_> Here is an implementation of callcc for OCaml using fork.
<mrvn_> You marshal the closure and fork for every time the callcc returns.
<Riastradh> How does: (('a -> 'b) 'a) -> 'a work?
<Riastradh> Shouldn't it be: (('a -> 'b) 'a) -> 'b ?
<mrvn_> the type inference will be right[tm] :)
<Riastradh> But, uh, that type means it returns a continuation, doesn't it?
coolduck has quit ["Client Exiting"]
<mrvn_> yes.
<Riastradh> And yet it needn't necessarily return a continuation.
<mrvn_> Thats the continuation you call if you want to get back to the point where callcc was called.
<Riastradh> But it looks like you can't return something other than the continuation.
<mrvn_> I don't think your suposed to
<Riastradh> Uh, why not?
<mrvn_> Where would you get the continuation from that callcc is suposed to save?
<Riastradh> callcc (fun k -> someGlobalVar := k; false)
<Riastradh> In, for example, an if statement.
<Riastradh> Or just generic nonlocal exits.
<mrvn_> callcc should be ('a cont -> 'a) -> 'a
<Riastradh> Zigackly.
<mrvn_> and here 'a cont is 'a->'b
<Riastradh> Oh, oops.
* Riastradh pokes M3.
<Riastradh> Er, wrong window.
<mrvn_> continuations are somewhat realy hard to grasp.
docelic has left #ocaml []
<Smerdyakov> No! They're just setjmp and longjmp!!!
<Smerdyakov> It's almost time to talk about continuations in Constructive Logic class.
<Smerdyakov> Apparently they are related to a transformation from proofs in classical logic to constructive logic.
<mrvn_> Smerdyakov: can one use setjmp/longjmp in c code linked into ocaml?
<mrvn_> Would the GC go berserk if thats used?
<Smerdyakov> mrvn_, I don't know!
<mrvn_> Something to try out tomorrow. I crashed my ocaml enough times today.
<Smerdyakov> So what! I crashed SML/NJ!
<Smerdyakov> Unsafe.cast 0 0;
<Smerdyakov> BOOM
<mrvn_> I never though you could get ocaml to segfault with a simple line.
<mrvn_> # Obj.field (Obj.repr 1) 0;;
<mrvn_> zsh: segmentation fault ocaml
<mrvn_> They could have checked for "Obj.is_int" there
mrvn_ is now known as mrvn
<mrvn> I just whish there would be a function that returns the type of a value as string.
<mrvn> The static type that is, like "'a list"
* Smerdyakov faints.
<Riastradh> Is there any way to write native Mac GUI apps? ('native' meaning not using X11)
<whee> Riastradh: with cocoa :P
<Riastradh> Er, I meant in OCaml.
<Riastradh> I have a nasty tendency to omit random words.
<whee> I don't think so
<whee> I gave up looking a while ago
<Riastradh> Instead of going by the rule 'omit needless words!', I go by the rule 'include needless words and omit necessary words.'
<mrvn> There is Module Graphics
<whee> mrvn: that would use X11
<Riastradh> mrvn, but will it run on the Mac and without X11?
<Smerdyakov> Is there any wxWindows interface?
<mrvn> Does it? There is a X11 extension of it. But Graphics should run on Mac, Win and linux iirc
<Riastradh> Gack, no, death to wxWindows, I refuse to use it.
<whee> heh
<mrvn> Riastradh: If Graphics doesn't use native mac libs rewrite it.
<whee> Riastradh: if you're bored, do the bindings yourself :)
<mrvn> Can't be that hard to open a window, draw points, lines, boxes and circles and capture mouse/key events.
* Riastradh has no clue how to do that sort of thing, though.
<whee> those are haskell bindings, with all the fun done at compile time; you could do the same with camlp4
<whee> plus with ocaml having actual OO support, it shouldn't be that painful
<whee> I've just given up with doing native GUIs in other languages and just use Obj-C, though
<whee> it's a lot easier with IB, anyway
<systems> huh
<Riastradh> It seems to have been managed in Common LISP.
<whee> the haskell bindings are nicer than what's available in ruby and perl for example
<mrvn> Someone should design a proper GUI for and in ocaml.
<mrvn> All those bindings for C libs suck in some way or another.
<Smerdyakov> How about eXene for SML?
<systems> windowmaker is the most clean UI i saw ,i was told is uses libwings ...
<mrvn> dunno
<Riastradh> I think it would be easiest to use an Objective-C library, because it seems to me that Objective-C and OCaml are rather similar in terms of object system.
<systems> isnt easier to just learn and use one lang (and deal with it shortcomings), then learn a totally new lang? i been tryin for a while now (learn programming) and the progress is slow, there is a lot to learn and it requires a lot of memorization
<whee> it's easier to use the language for things it's designed for
<Riastradh> The more languages you learn the better; the wider the variety of problems you should be able to solve.
<systems> for example i read a book on c, and big parts from different books on python, a c tutorial ... and i think cant code for shit !!!
<Smerdyakov> There is not much memorization involved with programming.
<Smerdyakov> You should not have to make any effort to memorize anything.
<Riastradh> C isn't exactly a great programming language to learn as the first one you do.
<sproctor> yeah, BASIC, all the way.
* Riastradh stabs sproctor again, whether he wanted to die or not.
<sproctor> sorry, it had to be said.
<systems> well, i picked c, cause it's like a total opposite for python, so i thought i would see a bigger piece of programming picture this way, my interest in ocaml is mainly derived from that way of thinking
<systems> and i think it worked, ... it just takes more time then i thought
<Riastradh> Avoid C until you've grasped a few other programming languages first.
<Smerdyakov> Haskell is the one to learn first!
<Riastradh> No! Scheme!
<sproctor> scheme!
<whee> intercal!
<Smerdyakov> Maybe for dumpersons!
* Riastradh stabs whee, too.
<whee> I'm wearing armor! ha!
<systems> haskell is too academic, i also want to learn a lang that i can use in a real personal project, c python ocaml, for me looked like the winners
<Riastradh> Too 'academic?'
<Smerdyakov> You can very well use Haskell in "real personal projects"....
<Riastradh> Uh, if you're doing anything with CS, you're in academia.
<Smerdyakov> And Standard ML, too!
<systems> i think c is like crazy, the first function you learn in c is printf(), and till today i have no idea how printf is made, taking an arbitary number/type of parameters
<sproctor> read about va_list, etc.
<systems> i looked at the source of it, and got more confused i think it uses a macro thing
<mrvn> Look at Printf.printf :)
<Riastradh> Or avoid C until you've grasped a few other programming languages first.
<sproctor> what C book did you read?
<sproctor> there's only one worth reading.
<whee> I recommend "C for dummies" or "Learn C in 20 hours!"
<whee> :)
<systems> problem solving and program design in c , hanly koffman, and i read the online tutorial from the c channel
* Riastradh stabs whee again.
<sproctor> the C programming language is the only one.
<systems> nowadays i am readin the gnu c tutorial,
<Smerdyakov> sproctor, defend that assertion.
<sproctor> that is, if you're trying to learn C, not programming.
<systems> its better then anything i read before, but still missing
<sproctor> Smerdyakov: have you read a better book for learning C?
<Smerdyakov> sproctor, have you found a better proof that P is not equal to NP? =D
<systems> no
<Smerdyakov> systems, so you have no argument =P
<sproctor> Smerdyakov: ummm, you're losing me.
<systems> i download 600 MB of free and legal books from the net, am not gonna buy any new books
<sproctor> I can't tell if you're trying to prove or disprove my point.
<systems> no all c of course
<Smerdyakov> sproctor, the fact that a particular person hasn't read a book better than X doesn't meant that "X is _the_only_ book for Y"
<systems> i dont think a better book is the answer
<sproctor> Smerdyakov: you're right. but it still is the only book.
<mattam> systems: 600Mb of CS books ?
<systems> yes
<mattam> can you share them ?
<systems> how?
<mattam> i.e. can I download them ?
<systems> from me, i dont think so :(
<systems> I didnt mean to wet ur appetite, i just meant, the net if full of free papers and books the need to buy a book is nowadyas minimal
<systems> plus books are expensive
<mattam> yep, but some are really worth it
<Smerdyakov> I don't know about that, mattam!
<async> is there a way to break a while loop?
<Smerdyakov> At least for learning programming languages!
<mattam> and there aren't so many books, just a lot of papers and references
<systems> i thought about it, there is a lot of books for beginners and the expert needs only the man pages and the docs... the intermediate level or post beginners suffer the most
<systems> i think i can call my self post-beginner
<Smerdyakov> I only ever used 2 books to learn programming: old Waite Group C Primer++ and the ANSI C Standard
<Smerdyakov> Some BASIC books from the library, too :D
<Smerdyakov> And an old one from a book sale :O
<mattam> got QBasic from MS-Press :) (that's the only one)
<mattam> for programming, all is on the net, but when you want to investigate some new field in CS it's harder to find books (e.g. GP, distributed computing, AI techniques...)
<Smerdyakov> Then you can download papers....
<systems> actually i find on the net what i cant find in books, exactly smerdya , papers, masters and PhDthesis
<mattam> well, for a student like me, I prefer having a general introduction, then in-depth course then papers for bleeding edge. I might also not have found the good papers
<systems> the only advantages of books is paper ...tangible paper
<systems> take it to the bathroom and stuff
<mattam> but they cost too much to bring them when you're having a bath :(
<systems> paper isnt free
<mattam> bandwidth neither
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
systems has quit ["Client Exiting"]
mattam has quit ["http://lecul.ht.st"]
<pattern> gp books are mostly worthless
<pattern> all the cool stuff is in papers on citeseer :)
<pattern> heh! i just found some #ocaml logs, dating back as far as 2001 -> http://tunes.org/~nef/logs/ocaml/
sproctor has quit ["I like core dumps"]
phubuh has joined #ocaml
<phubuh> how do i make a regular expression non-greedy in ocamllex?
<pattern> for anyone who cares, the asmdynlink library in the CDK has an "eval" http://pauillac.inria.fr/cdk/newdoc/htmlman/cdk_48.html#SEC53
rox is now known as rox|rathaus
det has joined #ocaml
<async> why do some programs have let "fun _ =" so many times
<async> what does the _ do?
<det> anonymous argument, I think
<det> or maybe not
keebler has joined #ocaml
<keebler> <cluebie alert> can someone point me to an example of mutual recursion in ocaml?
<pattern> search for "Mutually recursive"
<keebler> aha, thanks
<pattern> :)
lament has joined #ocaml
det has quit ["ircII EPIC4-1.1.2 -- Are we there yet?"]
keebler has left #ocaml []
skylan has quit ["Reconnecting"]
skylan has joined #ocaml
xxd has joined #ocaml
Kinners has left #ocaml []
coolduck has joined #ocaml
pattern has quit ["..."]
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
pattern has joined #ocaml
pattern has left #ocaml []
pattern has joined #ocaml
pattern has quit [Client Quit]
pattern has joined #ocaml
<pattern> does anyone know how to submit phrases/selections of ocaml source in vim to the toplevel and see the errors from within vim, without actually saving a file
TachYon76 has joined #ocaml
<pattern> it's possible in emacs... i'm guessing it _should_ be possible in vim
TachYon76 has quit [Remote closed the connection]
<pattern> ok... this is how you do it:
<pattern> make your selection
<pattern> then type: ":w !ocaml"
<pattern> i've now mapped that to F2 -> "map <F2> :w !ocaml"
<pattern> and it works great :)
Zadeh has quit [Read error: 104 (Connection reset by peer)]
foxster has joined #ocaml
coolduck has quit [Remote closed the connection]
rox|rathaus is now known as rox
mattam has joined #ocaml
esabb has joined #ocaml
<mrvn> So ne schoene runde Pizza ....
<mrvn> ups
mellum has quit [Read error: 110 (Connection timed out)]
mellum has joined #ocaml
esabb has quit ["Client Exiting"]
coolduck has joined #ocaml
phubuh has quit [Remote closed the connection]
Yurik has joined #ocaml
phubuh has joined #ocaml
<phubuh> hey duderoos
<Yurik> re
<Riastradh> Hi.
phubuh` has joined #ocaml
phubuh has quit [Read error: 104 (Connection reset by peer)]
Yurik has quit [Read error: 54 (Connection reset by peer)]
phubuh` is now known as phubuh
<phubuh> hey
<phubuh> I can't quite grok %left et al. in ocamlyacc
<Smerdyakov> left associative operators
<mrvn> a - b - c is (a - b) - c
<phubuh> a - b - c - d is ((a - b) - c) - d?
<gl> yes
<mrvn> exp = exp - exp
<gl> LALR(1)...
<mrvn> The associativeness says if it (a-b)-c or a-(b-c)
<phubuh> I'm (incestously enough) writing a grammar for BNF. I have the tokens string_literal, identifier, plus, star, question, assign, pipe, lparen, rparen, and eol. should everything be nonassoc, except for pipe, which should be right?
<Smerdyakov> How does a nonassoc binary operator work? O_o
<mrvn> you have your precedence right? a+b*c = a+(b*c)?
<Smerdyakov> You get whatever it wants?
<mrvn> Smerdyakov: you get what the default is
<Smerdyakov> OK
<phubuh> assign can be used only once per rule, so the default should so fine
<phubuh> why did I say so? the default should _be_ fine
<mrvn> you find out soon enough if you run a few test cases
<async> if i have: let main () = begin .... end, why does it give a "This expression is not a function, it cannot be applied" error?
<async> but if i take out the begin/end it works
mrvn_ has joined #ocaml
coolduck has quit ["Client Exiting"]
mrvn has quit [Read error: 110 (Connection timed out)]
TachYon26 has joined #ocaml
<async> how to you convert a string into an int?
<async> something like "\0x23\0xFF" into 23FF
<whee> use scanf
<whee> something in the scanf module, even
<async> yeah thats a lot easier than what i was thinking
<async> i was thinking bitwise shifts and lor
phubuh has quit [Read error: 104 (Connection reset by peer)]
<mrvn_> Obj.magic if you know its a full int
mrvn_ is now known as mrvn
<mellum> mrvn: Hmm, doesn't sound like good general purpose advice ;)
<async> does anyone have an example of scanf?
foxen has joined #ocaml
<mrvn> # Scanf.scanf "%d" (fun x->x);;
<mrvn> 17
<mrvn> - : int = 17
<mrvn> # Scanf.scanf "%d %f" (fun x y -> (x, y));;
<mrvn> 17 1.4
<mrvn> - : int * float = (17, 1.4)
<Smerdyakov> Hm. Why bother to have that 2nd parameter?
<mrvn> because scanf wants one
<Smerdyakov> Why did they design it that way?
<mrvn> What should scanf do with the values it reads?
TachYon26 has quit ["bez ki³y nie ma zaliczenia (z prawd studentek AM)"]
<mrvn> They could have made a scanf that returns a tuple of all values but with currying that can be more efficient.
<mrvn> (i guess)
<Smerdyakov> OK.... =D
<whee> it's still more flexible if it takes any function with the correct type
<Smerdyakov> Not especially.... you could just apply the function to the result of scanf if it returned a tuple.
<mrvn> whee: f (Scanf.scanf "%d %f") would be as flexible as Scanf.scanf "%d %f" f
<whee> yes, but you may or may not need that tuple
<mrvn> but of cause without () is nicer :)
<Riastradh> The latter is simply CPS.
<async> hmm scanf only converts strings like "12345" into numbers.. how can you cast a string into an integer?
<mrvn> async: you mean a byte stream?
<whee> using something in the scanf module
<async> yes
<mrvn> val input_binary_int : in_channel -> int
<mrvn> Read an integer encoded in binary format from the given input channel. See Pervasives.output_binary_int. Raise End_of_file if an end of file was reached while reading the integer.
<mrvn> probably doesn't help
foxster has quit [Connection timed out]
<mrvn> async: 1,2,4 or 8 chars?
<mrvn> or variable?
<mrvn> Big or little endian?
<async> big endian
<async> 4 chars
<mrvn> let num s = ((int_of_char s[0]) lsl 24) + ((int_of_char s[1]) lsl 16) + ...
<mrvn> You might want to use Int32 or NativeInt.
<mrvn> normal ints might be too small
<async> is it usually better to work with input/output channels instead of Unix file descriptors?
<async> the input_binary_int works beautifully
<async> thanks
<async> mrvn:
gene9 has joined #ocaml
gene9 has quit [Client Quit]
sproctor has joined #ocaml
coolduck has joined #ocaml
coolduck has quit ["Client Exiting"]
mrvn has quit [leguin.freenode.net irc.freenode.net]
Riastradh has quit [leguin.freenode.net irc.freenode.net]
rox has quit [leguin.freenode.net irc.freenode.net]
polin8 has quit [leguin.freenode.net irc.freenode.net]
mrvn has joined #ocaml
Riastradh has joined #ocaml
rox has joined #ocaml
polin8 has joined #ocaml
asqui has quit [Excess Flood]
asquii has joined #ocaml
asquii is now known as asqui