<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 :-'
<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 :)
<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
<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)]