<araujo>
but i am interested to look into ocaml's scripting capabilities :-)
<shekmalhen>
'k
<shekmalhen>
never tried haskel yet
<shekmalhen>
youknow365, seems better
<araujo>
shekmalhen, a beautiful language
<araujo>
though i think ocaml got better support for scripting
<shekmalhen>
by scripting you mean?
* shekmalhen
is generally not fond of "pure" languages
<araujo>
to manipulate other programms and processes
Snark has joined #ocaml
<shekmalhen>
'k
<shekmalhen>
with ocaml's unix module?
<araujo>
shekmalhen, they are beautiful in its own way.
* araujo
has used mostly pure languages
<araujo>
shekmalhen, yes, and the fact you can use ocamlrun to interpret programms
<araujo>
from commandline that is
<shekmalhen>
but you need to bytecompile the program first
<shekmalhen>
maybe using a toplevel?
<araujo>
Though i _do_ understand that pure languages usually build too many theoretical barriers which people wouldn't like to mess with
<shekmalhen>
my idea is to use what's best for this situation.
<araujo>
shekmalhen, you mean, with ocamlrun?
<shekmalhen>
multi-paradigm languages offer more freedom in this manner
<shekmalhen>
araujo, no, ocaml and other toplevels created by ocamltop
<araujo>
well, i am pretty much re-learning ocaml , i checked you can write a programm with #!/usr/bin/ocamlrun , a la shell script...
<araujo>
shekmalhen, yes , it is not like pure languages aren't able to use other paradigms. But that usually implies some kind of emulation which the user doesn't want to deal with.
<araujo>
My point about the theoretical aspects.
<shekmalhen>
I see
<shekmalhen>
and it is perfectly valid.
<araujo>
That got many cons and pros , it pretty much depends upon what you want to use.
<shekmalhen>
where $source_file is your source file
<youknow365>
it just displayed the code ?
<shekmalhen>
the code is parsed and dumped back.
<shekmalhen>
It might help to see what the parser understand
<youknow365>
its the same
<youknow365>
formatted al ittle different
<youknow365>
shekmalhen: what does that mean when its parsed ?
<youknow365>
i dont get what its doing
<youknow365>
or how it could help me
<shekmalhen>
the compiler and the interpreter need to read and understand the program text
<shekmalhen>
it is parsing.
<shekmalhen>
It stores it in memory in a way that it makes sense to it so it could either execute the code or make bytecode or machine code out of it
<shekmalhen>
but what I gave you dump the program back in ocaml form.
<youknow365>
what it gave back is a little different then what i have ?
<shekmalhen>
yeah
<youknow365>
not much but a little
<youknow365>
what does this mean
<shekmalhen>
but it is really the way that it understand the program
<youknow365>
so what can i accomplish bvyt doing this ?
<shekmalhen>
if there was a slight syntax error, it would show up drastically different
<shekmalhen>
it is a tool that can help you to understand what is happening; it is useful when you have too few information about the problem and that the parser gives cryptic error messages
<youknow365>
it just says syntax error line 10
<youknow365>
but
<youknow365>
let client_sock = Unix.socket PF_INET SOCK_STREAM 0 in
<youknow365>
if anyone in here is a ocaml guru please let me know
_jol_ has joined #ocaml
_jol_ has quit [Read error: 113 (No route to host)]
pango__ is now known as pango
<pango>
youknow365: before let client_sock ... you need either ;; or let _ =
smimou has joined #ocaml
Snark has quit ["Leaving"]
mnemonic has joined #ocaml
mnemonic has quit [Read error: 104 (Connection reset by peer)]
mnemonic has joined #ocaml
mnemonic has quit [Read error: 104 (Connection reset by peer)]
mnemonic has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
<oracle1>
anyone has debian apt sources.list entries for ocaml 3.09.2 ?
<pango>
oracle1: for stable I guess ? Nothing in backports or apt-get.org... You could probably recompile testing version with stable...
mnemonic has quit [Read error: 104 (Connection reset by peer)]
<pango>
sudo apt-get build-dep ocaml, apt-get source ocaml, cd ocaml-3.09.2, dpkg-buildpackage -rfakeroot -b -uc, and you should get something like http://concept.free.free.fr/ocaml/3.09-for-sarge/ ... but depending on what you'll using it for, you'll probably have to recompile other libs too...
basti_ has joined #ocaml
ziggurat has quit ["Leaving"]
slipstream has joined #ocaml
_jol_ has joined #ocaml
<_jol_>
hello dear camlers,
<basti_>
hi
<_jol_>
does anyone know why the following isn't valid :
<_jol_>
type my_type = {my_attr:int} Lazy.t;;
<_jol_>
?
<pango>
try type my_record_type = { my_attr:int } and my_type = my_record_type Lazy.t
<_jol_>
indeed, it works. But why isn't the former a valid type declaration ?
<pango>
http://caml.inria.fr/pub/docs/manual-ocaml/manual012.html: "There are no type expressions describing (defined) variant types nor record types, since those are always named, i.e. defined before use and referred to by name.". As for the "why", I don't know
<_jol_>
ok, i just wondered if it was a known behaviour. thanks for your answers.
<pango>
I suppose that any type that can appear in expressions while constructing or deconstructing datastructures must be named (for error reporting, and maybe more)
<basti_>
is there some rudimentary http server in ocaml somewhere?
<youknow365>
so if i prefix those i dont need it right ?
<pango>
yes
<youknow365>
whats better ot do prefix or jus take out the Unix. and just add open Unix ?
<pango>
depends on the case
<pango>
in this case, you're using the Unix module a lot, and identifiers defined in Unix will probably not clash with other names, so I think it's ok to use open
<pango>
datastructure modules (list, array, etc.) often all define the same names (create, get, set, length...) so it's usually not wise to open them
<youknow365>
i seeeeeee
<youknow365>
ok so .......it worked but do i need these cmo and cmi files to run the program ?
<youknow365>
or are those like .o files for C
Carillon_ has joined #ocaml
<youknow365>
i mean the same thing
<basti_>
cmo is comparable to .o
<pango>
cmi is compiled module interface, cmo is compiled module implementation
<pango>
let result = sock_send in ... will declare a new function called result, that's an alias on sock_send
<youknow365>
yea
<pango>
what you want is the value of sock_send client_sock "teeeeeeeeeeeeest\n", so you want let result = sock_send client_sock "teeeeeeeeeeeeest\n" ...
<pango>
oups, forgot the "in"
<pango>
let result = sock_send client_sock "teeeeeeeeeeeeest\n" in ...
<youknow365>
ooo
<pango>
let in construct stops and the end of the sequence after it, so result scope will continue until the end of your program, and it will just work
<youknow365>
i will try to understand whwhat you just said in one moment :P
<pango>
in "let v = e in e1; e2", v scope is "e1; e2"
<pango>
youknow365: btw, you already did this with client_sock, so you shouldn't be surprized ;)
<basti_>
mmm ocsigen doesn't seem to find my modules
<basti_>
or can't call
mpc has quit []
gn has joined #ocaml
<youknow365>
ok cool workd 17 bytes
<youknow365>
the C equivalent to this is almost twice as long
<youknow365>
sock_recv << what is this for again ?
<basti_>
heh. ocaml is pretty terse - you won't notice how terse it really is until you see a more serious example
<basti_>
it recieves n bytes from a socket
<youknow365>
terse?
<basti_>
small
<youknow365>
ahhhh
<youknow365>
well i am doiing some GTK stuff and this socket thing and yea
<youknow365>
in real world everytime i send something over a socket should i do a check to make sure it got sent ?
<youknow365>
or is that not needed
mpc has joined #ocaml
<basti_>
hmm
<basti_>
let's put it like that: you -should-, somehow
<basti_>
the trick is: if you didn't send all the data, then something is majorly fucked up anyway, and it'll be ok to crash and burn
<youknow365>
so not needed right ?
<basti_>
it'll bite you some time
<basti_>
but in reality noone ever checks
<basti_>
youknow365: a good practice (and good for your practice) would probably be to write a function that at least fails with a half-way sane message in that case
<basti_>
like sock_send_check "..."
gn has quit []
mnemonic has joined #ocaml
<mnemonic>
hi
<basti_>
hi
shawn__ has joined #ocaml
<youknow365>
basti_: can you explain for me how to listen on the same port ?
<youknow365>
basically on port 4550 i want to send packets and listen for new ones
<basti_>
you're aware that listening on a port and recieving packets over an established connection are different things?
<youknow365>
yes i do
<youknow365>
of course :P
<basti_>
so do you want to listen on a port, or recieve incoming packets?
<youknow365>
but theres a recv_sock thingright which is for that ?
<youknow365>
wellll
<basti_>
that's for recieving packets on an already open connection
<youknow365>
to recive incoming packets dont you have to be listening
<youknow365>
this is for IM
<basti_>
no, you can as well recieve packets from a connection you initiated
<youknow365>
send im messages on speicifc port recieve im messages on same port
<basti_>
well this depends on what you want to achieve...
<youknow365>
that would seem to work since i want sending and reciveing of IM to be on same port
<basti_>
first, you're sending on an entirely different "source port"
<youknow365>
huh?
<basti_>
if you send -to- port 1234, you might be sending -from- port 4824
<basti_>
usually you don't specify this part
<youknow365>
i kinda get you .......
<basti_>
you you should learn how TCP and UDP work
<youknow365>
3i will be sending ims to a jabber server on port 4550
<basti_>
see, then you'll only need to connect to the server
<basti_>
you'll recieve messages over the very same connection
<youknow365>
im sorry i used listen in a differ context
<basti_>
"listen" is a valid term here, but it describes something else
<basti_>
listening is what the server does until you connect
<youknow365>
yes
<youknow365>
vnc --listen
<youknow365>
etc
* basti_
nods
<youknow365>
yea so
<basti_>
you'll only have to recieve.
<youknow365>
i use the recv_sock thing for reciving packets on the same connection right ?
<basti_>
yep
<youknow365>
but last time i did that it waited
<basti_>
yes, it'll wait for a message to come ^^
<youknow365>
i need ot be able to send ims and recive them at the same time
<basti_>
i agree completely.
<youknow365>
anbd the 1024 thing ?
<basti_>
1024 means: wait for 1024 bytes
<youknow365>
whats for what .........how amny bytes i am going to be reciving ?
<basti_>
that will give a problem unless your message is exactly 1024 bytes long
<youknow365>
i have no idea how many bytes could come ?
<basti_>
you can ask the OS how many bytes are in the buffer
<basti_>
and thus avoid blocking
<basti_>
i think, select does this.
<youknow365>
i seeeee
<youknow365>
select wor kon linux and windows ?
<youknow365>
work
<basti_>
i think so, yes.
<youknow365>
i remmeber gnutls had a problem with select not working the same or something on windows
<basti_>
i bet there's a higher level way, too, somewhere
<youknow365>
hmmmmmm
<youknow365>
where ca n i research this at ?
<basti_>
maybe you look at examples?
<youknow365>
:)
<youknow365>
i dont find too many ocaml examples on the internet
<basti_>
i bet, many programs do this kind of stuff
<youknow365>
i said internet lol
<basti_>
:D
<youknow365>
you mean find a C equivalent ?
<basti_>
no why. any bet there's an ocaml example that does this stuff
<youknow365>
where do you find ocaml examples at ?
<basti_>
google?
<youknow365>
ok i will search but whats this called ?
<youknow365>
after i get these 2 little things done it should be pretty easy