mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.0 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
essiene has quit ["leaving"]
Smerdyakov has quit ["Leaving"]
Smerdyakov has joined #ocaml
zarvok has joined #ocaml
smimou has quit ["bli"]
G_ has joined #ocaml
G has quit [Connection timed out]
buluca has quit [Read error: 113 (No route to host)]
ita has quit [Remote closed the connection]
baruk has quit ["Lost terminal"]
Tac-Tics has joined #ocaml
seafoodX has joined #ocaml
thermoplyae has joined #ocaml
<thermoplyae> to reiterate from 3am: can vals in objects be made private, or otherwise hidden from outside view?
aminorex has joined #ocaml
G has joined #ocaml
G_ has quit [Connection timed out]
G_ has joined #ocaml
threeve has quit []
G has quit [Read error: 110 (Connection timed out)]
bzzbzz has quit ["leaving"]
G has joined #ocaml
zarvok has quit ["BitchX-1.1-final -- just do it."]
G_ has quit [Read error: 110 (Connection timed out)]
<flux> thermoplyae, they cannot be made public
<flux> thermoplyae, so: not really, because they are private by default :)
<thermoplyae> oh, really? i guess i never tried to access one, i just saw them in the signature and got worried
<thermoplyae> thanks for making me not stupid
<flux> I would've thought the fact that they aren't visible after defining the object would've been a good hint.. ;-)
<flux> object val a = 42 method get_a = a end;;
<flux> well, the bot isn't around here now, but that's something you can write to ocaml toplevel
<thermoplyae> right
<thermoplyae> i just didn't know if i was missing an operator somewhere that would let you index in
<thermoplyae> anyway, thanks again for the obvious answer
<thermoplyae> turns out i had more serious issues anyway; i didn't realize int was 31 bits wide
<thermoplyae> thanks a third time
thermoplyae has left #ocaml []
olegfink has quit [Read error: 104 (Connection reset by peer)]
olegfink has joined #ocaml
Tac-Tics has left #ocaml []
ygrek has joined #ocaml
cmeme has quit ["Client terminated by server"]
cmeme has joined #ocaml
zvrba has joined #ocaml
l_a_m has joined #ocaml
<G> rwmjones: poke
essiene has joined #ocaml
<essiene> morning/evening ppls
<essiene> initially i had a monolithic program that worked... i now decided to break it up a bit and now i get the following error:
<essiene> File socket.ml, line 16, characters 37-39: Syntax error
<flux> essiene, top level let definitions don't have 'in'
<essiene> wow!
<flux> essiene, perhaps you want: let _ = let sd = ez_connect .. in ez_send ..
<essiene> flux: i didn't know that... thnx... so i probably am better off putting everything into another function and calling that function. no? but i don't understand the let _, i know _ is used in match expressions to catch all other matches, just don't understand it here
<flux> essiene, btw, I would suggest you to indent the "let in"s so that they are in the same level as the previous let in, if there are no intermediate expressions
<flux> essiene, the well, you could just as well write let foo = ..
<flux> essiene, the code for defining foo is evaluated when the file is evaluated
<flux> but if you don't want to assign a name to the value, you can just use _
<essiene> hmmmm...
<essiene> thnx... lemme chew on all that
<flux> you can use let () = also if you want to explicitly state that the statements will return a unit value (that is: nothing of interest)
<essiene> ok
<rwmjones> G pong
<essiene> flux:
<essiene> flux: can i say its generally a good practice to always have a 'main' like function in the toplevel of your program and then call that instead?
<flux> essiene, yes, I do that
<essiene> ok... thnx
<flux> essiene, I sometimes even do this: let main args = .. let _ = main (List.tl (Array.to_list Sys.argv))
<flux> it can be difficult to modify a program that has many side-effectul top-level definitions
<essiene> hmmmm... i see
<essiene> you know this is my third attempt at functional languages (Haskell, Erlang previously) and this is the first time I can actually do something use full! :)
<essiene> i guess its partly because ocaml is not *purely* functional...
<essiene> one thing that I don't know how other deal with is the need to specify all arguments to a function... since there's no concept of function overloading or default arguments (at least that i've come across yet)
<flux> hm, ocaml has labeled and default arguments
<flux> perhaps glancing through the manual once would be a good idea ;-)
<flux> but yes, no function overloading
<essiene> flux: i'm doing a combination of read some, dirty hands some... makes me feel more productive :)
<flux> at times I would also like that too, and infact there is a project that provide something like that (gcaml)
<essiene> flux: i had to look thru the unix.mli on my system to figure out how to use the sockets interface... and some of the functions like send, recv, didn't have default args for stuff i thought should be made defaults
<essiene> yeah... overloading is cool at times... though i've had to live without it with Python, so i don't really mind it soo much these days
<flux> well, the documentation for Unix is generated from unix.mli so that's an allright approach
smimou has joined #ocaml
<essiene> yeah... i didn't know about the module index on the web till yesternite
<flux> really, just glance through the documentation, not really even read it, so you'll get an idea what it has :)
<essiene> ok then
<essiene> thnx for your time... really appreciated
essiene has quit ["leaving"]
buluca has joined #ocaml
G_ has joined #ocaml
G has quit [Read error: 110 (Connection timed out)]
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
seafoodX has quit []
ita has joined #ocaml
smimram has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
seafoodX has joined #ocaml
Oatschool has quit [Read error: 110 (Connection timed out)]
Oatschool has joined #ocaml
screwt846 has quit [Remote closed the connection]
Abo-Marwan47 has quit [Remote closed the connection]
Abo-Marwan has joined #ocaml
kelaouchi has quit ["leaving"]
screwt8 has joined #ocaml
Mr_Awesome has joined #ocaml
piggybox_ has quit [Connection timed out]
seafoodX has quit []
buluca has quit [Read error: 113 (No route to host)]
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
piggybox has joined #ocaml
xavierbot has joined #ocaml
screwt8 has quit [Remote closed the connection]
Abo-Marwan has quit [Remote closed the connection]
mordaunt has quit [Connection reset by peer]
seafoodX has joined #ocaml
seafoodX has quit []
Tetsuo has joined #ocaml
Abo-Marwan has joined #ocaml
screwt8 has joined #ocaml
Abo-Marwan has quit [Remote closed the connection]
screwt8 has quit [Remote closed the connection]
pango has quit [Remote closed the connection]
pango has joined #ocaml
crathman has joined #ocaml
Abo-Marwan has joined #ocaml
screwt8 has joined #ocaml
piggybox_ has joined #ocaml
buluca has joined #ocaml
Mr_Awesome has joined #ocaml
piggybox has quit [Read error: 110 (Connection timed out)]
screwt8 has left #ocaml []
Abo-Marwan has quit [Remote closed the connection]
crathman has quit ["ChatZilla 0.9.78.1 [Firefox 2.0.0.7/2007091417]"]
Tetsuo has quit [Read error: 104 (Connection reset by peer)]
Tetsuo has joined #ocaml
Abo-Marwan has joined #ocaml
Tetsuo has quit [Remote closed the connection]
bluestorm has joined #ocaml
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
screwt8 has joined #ocaml
screwt8 has quit [Remote closed the connection]
Abo-Marwan has quit [Remote closed the connection]
Tetsuo has joined #ocaml
pants1 has quit [Read error: 110 (Connection timed out)]
postalchris has joined #ocaml
pants1 has joined #ocaml
pcc has joined #ocaml
pcc has left #ocaml []
pants1 has quit [Read error: 110 (Connection timed out)]
Abo-Marwan has joined #ocaml
essiene has joined #ocaml
<essiene> halo ppls :)
<ita> hola
<essiene> hey ita: i've been playing around and really enjoying ocaml generally :)
<essiene> i'm worried though... it doesn't feel too different from say my current programming practice in Python... so i'm worried i'm not groking the *ocaml* in ocaml
screwt8 has joined #ocaml
<essiene> in python... i always keep all things happening in functions... avoid global scopes, break things up, etc... so i think right now i'm writting python programs in ocaml
<pango> that's a rough description of modular programming
<essiene> pango: yeah.. i guess :)
<pango> nothing specific to python or ocaml so far
skal has joined #ocaml
<bluestorm> hm
<essiene> pango: you're right... i guess i'm trying to say... now that i'm learning ocaml... i've not *felt* anything different apart from the syntax in my approach
<pango> you may find more differences in the type system (static against dynamic)
<bluestorm> maybe you need more fun involving recursion, algebraic data types and pattern matching :-'
<ita> essiene: http://people.csail.mit.edu/mikelin/ocaml+twt/ <- if you like python you will like twt
<essiene> pango: yeah, you're right... i must admit... i'm liking that safety and strictness... but not much more yet
<essiene> bluestorm: maybe its the problems i'm workign on then
<essiene> ita: checking... thnx
<essiene> ita: i'm not fanatical about twt ;)... vim ocaml mode is enough for me. sometimes i wish python wasn't too strict about it actually :)
<essiene> any more inbuilt module for strings apart from String.* ?
<bluestorm> Str has regexp search&replace
<essiene> oh.. ok... lemme check Str
<essiene> thnx
<pango> and Buffer
<essiene> thnx
rutlov has joined #ocaml
Tetsuo has quit ["Leaving"]
ygrek has quit [Remote closed the connection]
rutlov has left #ocaml []
psnively has joined #ocaml
<psnively> Hi guys. :-)
<essiene> hola!
<psnively> Guten Tag!
buluca has quit [No route to host]
buluca has joined #ocaml
<hnaz> moin
essiene_ has joined #ocaml
essiene_ has quit [Client Quit]
essiene has quit [Nick collision from services.]
essiene has joined #ocaml
skal has quit [Read error: 104 (Connection reset by peer)]
bluestorm has quit ["Konversation terminated!"]
<jonathanv> essiene, you aren't writing like a bunch of lines with ;s at the end are you
love-pingoo has quit ["Connection reset by pear"]
essiene has quit [Read error: 113 (No route to host)]
<jonathanv> he must have been ashamed when he realized what he was doing
essiene has joined #ocaml
<essiene> my first full _serious_ ocaml application! yay!
piggybox_ has quit [Read error: 110 (Connection timed out)]
<essiene> apart from the obvious gloat factor ;), i would appreciate any comments on style as related to ocaml best practices...
<essiene> thnx
<essiene> and i must say... the type checking thing is really really cool! i miss that in Python sometimes... but don't like the explicit definitions in C/Java at other times... i like the mix in ocaml
<psnively> Yep. Imagine that... convenience plus safety.
<essiene> one problem i had was a function evaluating to a tuple and when i try to do: let (a,b) = function_call in ... i had a syntax error
<essiene> i thought i could just unpack the tuple in a let assignment. no?
<psnively> Yes, e.g. let a, b = (1, 2)
<hcarty> essiene: For reference, you don't need the ;; to end a function
<psnively> You don't use the parens at the let; you use them to construct a tuple.
<essiene> hcarty: yeah i know.. but sometimes i got a syntax error i didn't know how to solve... i found that putting the ;; seemed to quieten the compiler :-/
<essiene> psnively: oh! dang!
<psnively> :-)
<essiene> psnively: thnx :)
<psnively> Anytime.
<psnively> BTW, the SMTP client is a nice learning exercise, but if you want a full-bore SMTP client and much more, check out Ocamlnet: http://ocamlnet.sourceforge.net/manual-2.2/
<essiene> thnx
<psnively> Sure thing!
<essiene> wow! that's a whole lotta functionality in ocamlnet
<psnively> Yep. :-D
pants1 has joined #ocaml
<essiene> i have just one more question... why is ocaml not recieving more *ahem* hype? :)
<psnively> Because it's from "academia." Remember, academia never does anything useful...
<essiene> psnively: ahh yes! i forgot that little detail ;)
<psnively> :-D
<pango> essiene: why is ez_recv only reading (at most) length - 1 characters ?
<essiene> pango: uhhh... so it doesn't overflow the buffer
<pango> (not to mention you throw away the number of characters actually read, so the function returns what's received, padded with random characters...)
<essiene> pango: bad thinking on my part?
<pango> essiene: overflow what buffer ? length characters are available
<essiene> pango: what am i talking about? uhhhh... my brain was slow there... my mistake
jsedgwick has joined #ocaml
jsedgwick has left #ocaml []
<psnively> Another good reason to use ocamlnet. ;-)
<essiene> hehe... point taken
<psnively> Nah, I'm teasing. Writing something you have an interest in is a great way to learn, even if implementations already exist.
<essiene> i think i want to jump on ocam[lex/yacc] now... that was one of the top secret reasons i learnt ocaml... wanna see all the noise about claims that functional languages make parser implementations a breeze :)
<essiene> psnively: i know you're teasing
<psnively> OK, good.
<essiene> oh... any defacto unit testing framework in ocaml?
<psnively> Well, they do... but you won't learn that from using ocamllex/ocamlyacc.
<essiene> perhaps on ocamlUnit?
<psnively> oUnit.
<essiene> psnively: hmm... you think i'll learn that better using raw ocaml itself than using the ocaml[lex/yacc] ?
<essiene> oh.. oUnit... was googling for ocamlUnit :)
<psnively> Usually, when people talking about parsing in functional languages, they're referring to a combinator library. There are several for OCaml.
<essiene> combinator library huh? whatever that means :)
<essiene> i have a confession to make though
<psnively> Yeah, it's a long story. Once nice library for OCaml is http://oops.tepkom.ru/projects/ostap
<ita> or about the manipulation of data structures which are easier in fp than in procedural programming (parsing is about making trees)
<psnively> I'll hear your confession, my child. :-D
<pango> essiene: in your program "main" is not a function
<essiene> one of the reasons i'm learnign ocaml is so that i can also throw terms like 'y-combinator' around at lesser suspecting programmers :P
<psnively> Heh.
<essiene> ita: i see
<psnively> Better yet, learn when it's appropriate to use the Y combinator. Hint: almost never.
<essiene> pango: huh? what is it then? ahh... wait it takes no argument! i should have made it take a unit. no?
<ita> psnively: debugging recursive functions ?
<pango> essiene: correct
<essiene> pango: but calling it by name still works why?
<psnively> ita: Perhaps.
<essiene> psnively: hehe... ok
<ita> psnively: debugging, optimization, adding layers of transformations, logging
<pango> essiene: its value is unit, so the last line just evaluate to unit
<pango> essiene: nothing evaluated... main is evaluated above
<ita> psnively: i use the y combinator quite often :-)
<psnively> ita: apparently! :-)
<essiene> pango: argh! thnx for pointing that out
<essiene> pango: that's probably why i kept having the syntax errors and had to use the ;; to force the compiler to keep shut
<pango> essiene: the other way is let () = main ()
<psnively> Or let _ = main()
<psnively> I can never remember why let () = main () works.
<essiene> ahh... ok... thnx tnx thnx guys...
<pango> essiene: see "Using and omitting ;; and ;" in http://www.ocaml-tutorial.org/the_structure_of_ocaml_programs
<psnively> That's what we're here for.
<pango> psnively: because if main () evaluates to unit (and it should), the let () = () pattern matching is happy
<psnively> Ah, right, of course. Thankx.
<pango> psnively: so let () = main () is slightly more strict than let _ = main ()
<psnively> Indeed.
<psnively> essiene: BTW, not all parsing in functional languages is done with combinators. Another popular parser generator for OCaml is http://dypgen.free.fr
essiene_ has joined #ocaml
essiene has quit [Nick collision from services.]
essiene_ is now known as essiene
jlouis_ has joined #ocaml
<jonathanv> i would say that that main reason there's not much ocaml hype is people don't comprehend the beauty of functional programming, and also, get scared off by the + +. +/ type stuff
Mr_Awesome has joined #ocaml
<ita> jonathanv: they are more scared about the a -> b -> c i think
<jonathanv> what, the arrows?
<ita> yes
<jonathanv> i like the arrows
<ita> they scare new users
<jonathanv> you pass an a, you get a b -> c
<jonathanv> that's the coolest thing ever
<ita> what is the type of that hashtable ? oh, Hashtbl t' ... surprize
<ita> int -> float -> int -> float
<essiene> :)
<ita> that's just too confusing when beginning
jlouis has quit [Read error: 110 (Connection timed out)]
<ita> then you come to #ocaml, begging for help and Smerdyakov replies in a very stern way "you obviously have not read the manual carefully enough"
skal has joined #ocaml
<essiene> lol
<Smerdyakov> No, I just say that people obviously haven't read the right part of the manual.
<noss> i think you are lining up things newbies find difficult, and not the things that put people off fp completly.
<noss> ...which are annoying preconceptions about fp being academic and "not useful in real world situations"
<ita> "and also, get scared off by the + +. +/ type stuff" <- there are scariest things than operators, aren't there ?
<jonathanv> the operators in ocaml are particularly tiresome
<ita> well well .. the =, == and === operators in javascript are too, at least the + and +. are pretty clear and give clear error messages
<jonathanv> but = and == do different things
<jonathanv> i don't know what === does since i don't know javascript
<ita> on the other hand, the semicolon, the (* *), the ! operator, the ^ and the @ or the :: are more scary
<ita> jonathanv: these operators are the source of killer typos
<pango> :: is not an operator
<ita> jonathanv: == is comparison with casting (an int can equal a string), while === checks the types (javascript)
<jonathanv> hmm
<ita> pango: i did not say so :-)
<jonathanv> i do not like it when an int can equal a string
<Smerdyakov> ita, no, that's wrong.
<Smerdyakov> jonathanv, don't worry; ita was just confused. :)
<jonathanv> however, my point is simply that = and == generally do different things, where + and +. do the same thing (with different types)
<pango> ita: oh, so PHP is not the only language with that === uglyness...
<ita> Smerdyakov: what is wrong ? :-)
<jonathanv> which is why i find = and == far more acceptable than + and +.
<ita> pango: no
<Smerdyakov> ita, just check the type of (==) and you'll see it's not heterogeneous.
<ita> jonathanv: well, the wrong one and nasty bugs arise
<ita> Smerdyakov: in javascript ?
<Smerdyakov> ita, in OCaml. I guess I misinterpreted your line as being about OCaml.
<ita> Smerdyakov: no, it was about operators in other languages versuse the specialized ones in ocaml
<ita> i think the ones in caml are really fine compared to what we can find elsewhere
<ita> at least the ocaml compiler does not eat the typos as others do
<psnively> OCaml really wants your code to make some semblance of sense. :-)
<jonathanv> you mean in if statements?
<jonathanv> like in C++?
<ita> jonathanv: like in c++ (but not only in the ifs)
<jonathanv> i just solve that by putting the constant value on the left if possible
<jonathanv> if (0 = makeanerrorcodemaybe(parameters)) {...
<jonathanv> compiler error
<ita> which is ugly and not encouraged by the language ..
<jonathanv> it's not that ugly
<psnively> Only works with non-lvalues...
<jonathanv> true, but works in many situations
<ita> not everywhere -> feeling insecurity
<jonathanv> haha
<psnively> Yeah. A major reason I like the ML family and Haskell is their massive levels of orthogonality.
<essiene> ok... time to call it a nite for today...
<essiene> thnx all for all the comments and pointers.
<psnively> Take care, essiene. :-)
<ita> essiene: sleep well
<pango> using == instead of =, or the reverse, and hide subtle bugs too
<essiene> cya
essiene has quit [""yawwwwn""]
<jonathanv> orthogonality means few side effects, right?
<ita> <a, b> = 0
<psnively> Orthogonality, in this sense, really refers to lack of special cases.
<psnively> The assign-to-lvalue trick causing a compile-time error in C/C++ is such a special case (actually, the distinction between lvalues and non-lvalues is the special case).
<hnaz> orthogonality means that most symbols can appear in most places
<hnaz> and that most code forms are treated equally
jlouis has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
EliasAmaral has quit [Remote closed the connection]
skal has quit [Remote closed the connection]
postalchris has left #ocaml []
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
jlouis_ has joined #ocaml