<async>
im trying to compile the Unix.openfile example from the oreilly book but im getting a syntax error. i compile my program with ocamlc -custom unix.cma fichiers.ml -cclib -lunix but it still doesn't work. Is there anything else I have to do?
foxster has quit [Read error: 54 (Connection reset by peer)]
<polin8>
what is the error?
<async>
File "camiso.ml", line 7, characters 71-73:
<async>
Syntax error
<whee>
and what's on that line?
<async>
hang on this vim is really pissing me off
<async>
let file = Unix.openfile "test.dat" [Unix.O_RDWR; Unix.O_CREAT] 0o644 ;
<whee>
that's an incorrect let construct
<whee>
let .. = .. in .. is the correct way
<async>
its straight from the book
<whee>
well, I guess that would work in the toplevel
<Kinners>
let a = b;; is ok
<async>
when i do a simpler thing from the Unix module it gives me a linking error
<whee>
# let file = Unix.openfile "test.dat" [Unix.O_RDWR; Unix.O_CREAT] 0o644;;
<whee>
val file : Unix.file_descr = <abstr>
<async>
Error while linking camiso.cmo: Reference to undefined global `Unix'
<async>
oh wait
<whee>
try running "ocaml unix.cma"
<async>
yeah it works
<async>
hmm it seems to work
<async>
just wrong compiler args
<async>
is there a way you can set the unix.cma to be a default linker option?
<async>
nvm i just added OCAMLLDFLAGS := -custom unix.cma to the makefile
<whee>
you could also use LIBS = unix with OCamlMakefile
<whee>
I would recommend that method
__mattam__ has quit ["try serious sam"]
foxster has joined #ocaml
Kinners has left #ocaml []
Smerdyakov has quit []
docelic has quit ["Client Exiting"]
Smerdyakov has joined #ocaml
docelic has joined #ocaml
docelic has quit [Remote closed the connection]
docelic has joined #ocaml
foxster has quit [Read error: 54 (Connection reset by peer)]
docelic is now known as docelic|away
foxster has joined #ocaml
jemfinch has joined #ocaml
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
jemfinch has quit [Read error: 104 (Connection reset by peer)]
jemfinch has joined #ocaml
lament has joined #ocaml
Yurik_ has joined #ocaml
Zadeh_ is now known as Zadeh
<Yurik_>
re
Yurik_ has quit [Read error: 54 (Connection reset by peer)]
Yurik_ has joined #ocaml
rox|beworben is now known as rox
Yurik_ has quit [Read error: 110 (Connection timed out)]
Yurik_ has joined #ocaml
Yurik_ is now known as Yurik
Yurik has quit [Read error: 54 (Connection reset by peer)]
Yurik has joined #ocaml
Yurik_ has joined #ocaml
Yurik has quit [Read error: 54 (Connection reset by peer)]
Yurik_ is now known as Yurik
TachYon26 has joined #ocaml
xtrm has joined #ocaml
rox is now known as rox|schwein
Yurik has quit [Read error: 104 (Connection reset by peer)]
Yurik has joined #ocaml
Yurik has quit [Client Quit]
xtrm has quit ["leaving"]
xtrm has joined #ocaml
TachYon26 has quit [Read error: 60 (Operation timed out)]
TachYon26 has joined #ocaml
Rhaaw has quit [Read error: 60 (Operation timed out)]
mattam has joined #ocaml
TachYon26 has quit [Read error: 60 (Operation timed out)]
Rhaaw has joined #ocaml
merriam has quit [leguin.freenode.net irc.freenode.net]
foxster has quit [leguin.freenode.net irc.freenode.net]
docelic|away has quit [leguin.freenode.net irc.freenode.net]
mrvn_ has quit [leguin.freenode.net irc.freenode.net]
mattam has quit [leguin.freenode.net irc.freenode.net]
Smerdyakov has quit [leguin.freenode.net irc.freenode.net]
async has quit [leguin.freenode.net irc.freenode.net]
steele has quit [leguin.freenode.net irc.freenode.net]
asqui has quit [leguin.freenode.net irc.freenode.net]
polin8 has quit [leguin.freenode.net irc.freenode.net]
xkb has quit [leguin.freenode.net irc.freenode.net]
Zadeh has quit [leguin.freenode.net irc.freenode.net]
xtrm has quit [leguin.freenode.net irc.freenode.net]
smkl has quit [leguin.freenode.net irc.freenode.net]
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
merriam has joined #ocaml
mattam has joined #ocaml
xtrm has joined #ocaml
foxster has joined #ocaml
docelic|away has joined #ocaml
Smerdyakov has joined #ocaml
async has joined #ocaml
mrvn_ has joined #ocaml
steele has joined #ocaml
asqui has joined #ocaml
polin8 has joined #ocaml
xkb has joined #ocaml
smkl has joined #ocaml
Zadeh has joined #ocaml
asqui has quit [Excess Flood]
asqui has joined #ocaml
mattam has quit ["leaving"]
TachYon26 has joined #ocaml
mattam has joined #ocaml
mattam has quit [Client Quit]
jemfinch has quit [Read error: 104 (Connection reset by peer)]
jemfinch has joined #ocaml
mellum_ has joined #ocaml
esabb has joined #ocaml
exa has joined #ocaml
mellum has quit [Read error: 110 (Connection timed out)]
mellum_ is now known as mellum
IRCMonkey has joined #ocaml
<Smerdyakov>
Haha! Monkey!
<exa>
:P
rox|schwein is now known as rox
jemfinch has quit [Read error: 60 (Operation timed out)]
mattam has joined #ocaml
exa has quit [Read error: 113 (No route to host)]
IRCMonkey has quit ["ChatZilla 0.8.11 [Mozilla rv:1.3a/20021212]"]
Dalroth has joined #ocaml
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
docelic|away is now known as docelic
esabb has quit ["Client Exiting"]
mattam has quit [Read error: 60 (Operation timed out)]
Smerdyakov has quit []
steele_ has joined #ocaml
steele has quit [Read error: 104 (Connection reset by peer)]
TachYon26 has quit [Remote closed the connection]
merriam has quit [leguin.freenode.net irc.freenode.net]
merriam has joined #ocaml
Rhaaw_ has joined #ocaml
Rhaaw has quit [Read error: 104 (Connection reset by peer)]
matkor has joined #ocaml
mrvn has joined #ocaml
phubuh has joined #ocaml
<phubuh>
how can i make a match .. with statement have a fallback case that gets evaluated if nothing else matches?
<mellum>
_ -> bla
<phubuh>
ah, i was thinking it was something like that. thanks!
<mrvn>
Is there a way to tell ocaml that I have an incomplete match here, that I know that, and that it should stop warning me about it?
<phubuh>
_ seems to match anything of any type. how can i restrict it to members of a specific type?
det has joined #ocaml
<mrvn>
phubuh: _ will only match the proper type.
<mellum>
phubuh: you mean a specific constructor?
<phubuh>
mrvn: oh, hmm :/
<mellum>
phubuh: Foo(_) should do
<det>
Does ocamlopt have problems on win98 ?
<mrvn>
phubuh: _ is a placeholder for any argument to be thrown away.
<mrvn>
let (x,_,z) = (1,2,3);;
<det>
I get an error when compiling anything with it
<whee>
mrvn: it won't stop warning you until you actually cover all the cases; even if you don't call it with something it doesn't cover
<whee>
there's nothing you can do about that
<mrvn>
whee: _ -> raise (Match_failure ("bla", 0, 0)) is a bit stupid since you loose some info.
<det>
$ ./ocamlopt.opt.exe -o hello hello.ml
<det>
Specified COMMAND search directory bad
<det>
Microsoft(R) Windows 98
<det>
(C)Copyright Microsoft Corp 1981-1999.
<det>
C:\ocaml\bin>
<whee>
well it has to do something :)
<phubuh>
hmm, well, I've got one type Postgres.Result.status, but when I try to match on two statuses and then _, it complains about the match type
<mrvn>
whee: something like _ -> #pragma raise
<mrvn>
phubuh: paste
<whee>
what would that do?
<mrvn>
whee: raise the normal match mismatch exception but cover the case.
<mrvn>
phubuh: Whats the return type of conn#do_command?
<phubuh>
hah, Postgres.result. i suppose that should be Postgres.Result.status =)
<mellum>
Why is everybody who uses Ocaml from France?
<phubuh>
beats me too
<whee>
inria is in france?
<mrvn>
I asked that last year already :)
<mellum>
mrvn: did you find out? :)
<det>
mellum: it seems to be developed by some french institute
<mellum>
det: well, that shouldn't matter that much in the Internet age...
<det>
what ocaml module does the equivalent of a system() call ?
<mrvn>
nope, still a mistery
<whee>
heh
karryall has joined #ocaml
<mrvn>
det: Unix.system
<det>
mellum, and only japanese use ruby :)
<whee>
ocaml is part of project cristal, which is one of inria's projects; inria is in france, hence the abundance of french developers :p
<mrvn>
steele_: leading / ist evil
<mrvn>
ups
<whee>
mrvn: you can get the input file and location via camlp4
<det>
does ocamlopt always compile to C before native code ?
<whee>
det: no, I don't think it goes to C at all
<whee>
it uses the linker, but not the compiler
<det>
whee, oh, that exmplains why I only get PATH error when linking with -o
<phubuh>
i declare an exception with "exception Invalid_session", but when i use it with "raise Invalid_session", i get Unbound constructor Invalid_session. what am i doing wrong?
<mrvn>
phubuh: you forgot the Module name
<phubuh>
do i need to when i'm in the definition of the interface where the exception is declared?
<phubuh>
heh, looks like i do. thanks!
<mrvn>
phubuh: normaly not
<mrvn>
But you have to have the exception in the mli and the ml file then iirc
<whee>
you want to put it in the ml, and in the mli if you want to allow it to be used in other modules
<phubuh>
oh, i see
<mrvn>
whee: If its only in the mli Module.Exception should still work, right?
<whee>
probably
<whee>
but it's less typing if you just include it in the ml as well
<det>
whee, if it uses gcc for linking then does the windows MSVC port of ocaml require msvc for lining ?
<whee>
yes, it does
<det>
ahh, ok
<matkor>
whee: Hm, so ocaml uses it's own native code assembler ? for each arch it supports ?
<whee>
matkor: yes
<det>
I've got ocaml compiled for mingw32 but ocamlopt is having trouble finding gcc which it apparently calls from Unix.System
<whee>
if it's in your path it should work fine
<det>
which uses command.com
<matkor>
whee: does ocamlcc have different oprimisers for each i386 flavor ? (i586, athlon, P IV) ?
<whee>
I don't think so
<det>
whee, I need to test what PATH is, how could I use Unix.System to run command.com /c echo %PATH% and record the output ?
<det>
or print it rather
<det>
n/m
<det>
actually, yes
<matkor>
whee: so what is minimal i386 CPU supported by ocaml nat. comp. ?
<whee>
286? :)
<whee>
well, probably the 386
<whee>
heh
<det>
hopefully not 286 :)
<whee>
being called i386 I would hope it supported at least that :)
<det>
# open Unix;;
<det>
# Unix.system;;
<det>
Reference to undefined global `Unix'
<mrvn>
Its probably more a question of what output you generate. On linux its allway 32 Bit, on i386 you could have 16 Bit code.
<det>
did I do something wrong ?
<mrvn>
det: you need unix.cma
<whee>
det: ocaml unix.cma
<mrvn>
s/i386/win,dos
<phubuh>
why do i have to initialize all variables in object?
<whee>
people can't possibly use windows or x86 anymore anyway :)
<mrvn>
What should there be otherwise?
<det>
whee, I need to pass ocaml all module I intend to use ?
<whee>
no, just ones that are externally linked like unix, str, num
<mrvn>
det: nope. Just the once not in your dir
<phubuh>
can't it just implicitly declare strings to be "" and such?
<det>
why .cma ?
<whee>
phubuh: what if someone else wants it to declare them as "I like cake"?
<mrvn>
phubuh: How should it know its a string?
<whee>
and that one, heh
<mrvn>
class foo = object val s end
<mrvn>
is s an int, string, char, something list?
<phubuh>
i've got that declared in my interface
<mrvn>
The interface is ignored until the very end
<phubuh>
oh
<mrvn>
(which I rather hate)
<phubuh>
i was just annoyed because "" and 0 seem so arbitrary
<phubuh>
i don't want to explicitly assign those to my variables, as if they mattered
<mrvn>
Anyone know how I create a class that has an reference to itself (without option type)
<whee>
what do you mean reference to itself D;
<mrvn>
phubuh: Then assign something that means something
<phubuh>
nothing does at the time :/
<det>
mrvn, maybe some Y combinator tricks on objects? :)
<mrvn>
whee: # class foo obj = object val p = ref obj end;;
<whee>
can't use self?
docelic is now known as nudedue
nudedue is now known as nudedude
<mrvn>
or val p = obj even
<mrvn>
# class foo obj = object(self) val p = self end;;
<mrvn>
The instance variable self
<mrvn>
cannot be accessed from the definition of another instance variable
<whee>
oh, yeah
<mrvn>
# let foo = new foo bar and bar = new foo foo;;
<mrvn>
Unbound value bar
<mrvn>
# let rec foo = new foo bar and bar = new foo foo;;
<mrvn>
This kind of expression is not allowed as right-hand side of `let rec'
<mrvn>
Not even two interlinked classes work
<mrvn>
# class foo = object(self) val mutable p = None initializer p <- Some self end;;
<mrvn>
class foo : object ('a) val mutable p : 'a option end
<whee>
well you can't directly reference self in the initializer because it's not created yet
<mrvn>
Thats the best I could come up with so far but then I allways have to match the option.
<whee>
how about using a method that returns self?
<mellum>
mrvn: BTW, there's a ocamlnet release with https support, perhaps it's of interest to you
<mrvn>
whee: can't call a method eigther. You would need self#method anyway.
<whee>
eh?
<whee>
# class foo a = object (self) method bloop = self; end;
<whee>
# let bling = new foo 1 in bling#bloop;
<whee>
- : foo = <obj>
<mrvn>
# class foo = object(self) val mutable p = self#me method me = self end;;
<mrvn>
The instance variable self
<mrvn>
cannot be accessed from the definition of another instance variable
<mrvn>
Thats the self in self#me
<whee>
oh, you want it modifible as well
<mrvn>
whee: not realy but its the only way.
nkoza has joined #ocaml
<whee>
what's wrong with the one I pasted?
nkoza has quit [Client Quit]
<whee>
I still don't see what you're trying to do I guess
<mrvn>
I could probably do some Obj.Magic thingy and initialize p with a bogus pointer and then correct that by overwriting it with self, but thats ugly.
<whee>
so what are you trying to do? heh
<mrvn>
whee: I have a bunch of classes for a GUI. Each class has a ref to its parent. Any drawing primitives are passed down to the parent until it hits the root, which actually draws.
<mrvn>
The base class is widget, which has a parent reference but the root can't be a widget because of that reference.
<whee>
so you want it to have a reference to self instead of a parent?
<mrvn>
whee: yep.
<mrvn>
whee: or to another dummy object
<whee>
hrm
<mrvn>
# class foo obj = object(self) val mutable p = Obj.magic 0 initializer p <- self end;;
<mrvn>
class foo : 'b -> object ('a) val mutable p : 'a end
<mrvn>
# let foo = new foo;;
<mrvn>
That would work, but its ugly.
<mrvn>
val foo : 'a -> foo = <fun>
<whee>
heh
<mrvn>
And I don't know what happens if the GC runs over the Obj.Magic 0
<phubuh>
i'm thinking of using it for a project, but i need to be able to read and set cookies
<mrvn>
The first wastes space for the option and the secodn even generates extra code for each instance.
<mrvn>
The thiord answere is in french so I have no clue what hes saying
<whee>
I don't think there's really a good solution
<whee>
besides going and initializing to a reference to some other dummy object that does nothing
<mrvn>
The Obj.magic is probably the best but segfaults if you make a mistake (like using p before the initializer has run
jemfinch has joined #ocaml
<whee>
well there's no obvious safe way that is :)
nudedude is now known as docelic
<phubuh>
i'm developing a web forum in ocaml. would it be expensive to generate binaries with ocamlopt and call those via CGI?
<whee>
depends on the overhead imposed by the OS
<whee>
(in creating the new process and blah blah)
<phubuh>
it would be running on a linux box with apache
<mrvn>
I noticed that record types are not initialized in the order given:
<mrvn>
# type foo = { first:int; second:int; }
<mrvn>
let first_init () = print_string "first\n";1
<mrvn>
let second_init () = print_string "second\n"; 2
<mrvn>
let bla = { first = first_init (); second = second_init (); };;
<mrvn>
second
<mrvn>
first
<mrvn>
Is that allways backwards?
<whee>
perhaps you want to approach it differently and not use ocaml for the interface
<mrvn>
phubuh: expensive? Yes, you have to pay be 1$ for every call.
<whee>
like use mod_perl or something else that remains loaded and have that interact with an ocaml daemon that handles all the fun
<whee>
mrvn: it might always be in that order right now, but it's not specified
<phubuh>
whee: there is a mod_ocaml on some site that seems to be down right now, but i don't know if it's any good
<mrvn>
phubuh: how long does your ocaml prog take to start and how many hits/day do you expect?
<whee>
you should use let blah = first_init () in bleh = second_init() in let foo = { first = blah; second = bleh } in .. if you want order to be specified
<whee>
and I missed a let in there, but you get the point
<mrvn>
whee: Yeah, i did that now but its a bit anoying.
<whee>
reach for camlp4 :)
<whee>
could add a syntax extension for that too, heh
<mrvn>
whee: My parser for some input files now reads: let read_foo () = let first = read_first () in let second = read_second () in { first=first; second=second; }
<mrvn>
And that for several records.
<mrvn>
Just doubles the number of lines :(
<phubuh>
i don't quite know how long it will take to start, as i haven't written it yet. as of now i'm expecting maybe three hits a minute, so for this project it wouldn't be an issue, but it might get used in a larger setting
<mrvn>
phubuh: If its to be used extensively you could implement a full http interface and do everything directly in ocaml, no buggy webserver inbetween.
<phubuh>
hmm, now there's an idea
<whee>
it wouldn't have to be that complex, just enough to handle the board
<mrvn>
As mellum said earlier theres a https implementation for ocaml.
<whee>
could run apache and that alongside each other
<phubuh>
oh, great, then i won't even have to write it myself, and i'll get ssl too
<mrvn>
yep. looks like it
<phubuh>
that's great
<mrvn>
Who is participating int the 11th PFC?
<mrvn>
-t
<whee>
I would, but cvs ocaml has some io problems and I'm too lazy to compile 3.06 :)
<phubuh>
do you happen to have a link or any other pointers to the mentioned https library?
<phubuh>
hmm, i found one on rouaix.org
<phubuh>
or no, that was just an SSL library
jemfinch has quit ["Client Exiting"]
jemfinch` has joined #ocaml
cm has joined #ocaml
polin8 has quit [Read error: 104 (Connection reset by peer)]
<whee>
for some reason I have the urge to try my hand at image processing
<phubuh>
mellum: aimed at me?
<cm>
whee: you're not referring to masturbation, are you? :P
<whee>
cm: I wasn't, but that also sounds good :)
<cm>
:P
<whee>
having fun relearning R and attempting to get this damn physics lab done at the moment :\
polin8 has joined #ocaml
jemfinch` has left #ocaml []
<mellum>
phubuh: yes, that's the https thingie, IIRC
<phubuh>
thanks, i'll check it uot
<phubuh>
out*
<phubuh>
hmm, why would a compilation work when compiled with ocamlc, but fail on the link process because it can't find Printexc__to_string_67 when compiled with ocamlopt?
<mrvn>
whee: apt-get install ocaml-3.06
<whee>
mrvn: not an option :P
<mrvn>
poor you
<mrvn>
my condolence
<whee>
haha
<whee>
I'll set up a fund for myself if you donate :0
det has quit ["ircII EPIC4-1.1.2 -- Are we there yet?"]
<mrvn>
I can donate an old debian cd
<whee>
I have one of those :(
<phubuh>
argh!
<phubuh>
this is weird
<whee>
what OS?
<whee>
(phubuh)
<phubuh>
debian :)
<whee>
it sounds like a bad compile to me :)
<phubuh>
ugh.
<phubuh>
=/
<mrvn>
phubuh: unstable?
<phubuh>
yep
<phubuh>
phubuh@igloo:~/poof/client$ ocamlopt -v
<phubuh>
The Objective Caml native-code compiler, version 3.06
<phubuh>
Standard library directory: /usr/lib/ocaml/3.06
<phubuh>
bugs.debian.org doesn't report anything serious about the package
<mrvn>
Works fine here Works fine here with unix.cmxa and graphics.cmxa