<al-maisan>
I am using Args.parse and something like "program -r -n" works whereas "program -rn" results in "./program: unknown option `-rn'." although both command lines are equivalent. Is this correct Args.parse behaviour?
<gildor>
I think I can generalize to variables accessible through ocamlc -config, but not further
<f[x]>
gildor, ok, thanks
<f[x]>
someone should definitely fix all those bugs :))
<gildor>
working on oasis-db and forge.o.o right now
<f[x]>
al-maisan, yes
<al-maisan>
hmm .. this is not quite how many programs work .. most of them support the grouping of flags i.e. both "-r -n" and "-rn" is acceptable.
<al-maisan>
example: rsync -a -v -z and rsync -avz etc.
init1 has joined #ocaml
<f[x]>
there are alternative arg parsing modules
ttamttam has quit [Remote host closed the connection]
<al-maisan>
ah, what are these?
<f[x]>
iirc extlib has one
ikaros has joined #ocaml
<al-maisan>
thanks, will take a look later.
_andre has quit [Quit: Lost terminal]
_andre has joined #ocaml
pdhborges has joined #ocaml
<pdhborges>
Hi I have a question about tags and blocks
<pdhborges>
the Is_long(x) macro checks if the lower bit of an mvalue is 1 or not
<pdhborges>
but the tag of the header of a block might also have a lower bit == 1
<pdhborges>
how does it distinguish a block from and int in that case?
munga has quit [Ping timeout: 264 seconds]
<f[x]>
the pointer is not the header
<f[x]>
it points to header
<pdhborges>
f[x]: so ocaml blocks are never allocated at adresses ending in 0?
<pdhborges>
s/0/1
<pdhborges>
s/adresses/#define Is_long(x)
ygrek has quit [Ping timeout: 245 seconds]
<pdhborges>
ups
<f[x]>
yes, all allocations are aligned at 2 or 4 bytes (do not remember exactly)
<pdhborges>
thanks!
munga has joined #ocaml
mnabil_ has joined #ocaml
<thelema>
al-maisan: ocaml doesn't use gnu-style single-dash short arguments and double-dash long arguments, all arguments have one dash (thus, no grouping of short ones)
<thelema>
f[x]: 4B (or 8B on 64-bit)
<al-maisan>
thelema: thanks for the explanation!
* al-maisan
is used to gnu-style command line args ..
<thelema>
al-maisan: it's frustrating for me too, if you're still looking for a gnu-style command-line library, I've written one... somewhere...
<flux>
what is the best command line argument processor library for ocaml, if the criteria are: 1) DRY 2) little code for new options 3) gnu-style?
<adrien>
there's a getopt module from Alain Frisch too
<flux>
I guess to optimize two first one might think of a syntax extension..
<adrien>
gnu-style meaning -cJf is equivalent to -c -J -f ?
<al-maisan>
adrien: yeah .. I saw that .. there's even a package on ubuntu for it (libgetopt-ocaml-dev); will play with that and see how it goes..
<al-maisan>
adrien: gnu-style also means long "versions" of options e.g. --help
<flux>
well, both --long-args and traditional and arg0 -cJf arg1 arg2 <=> arg0 -c arg1 -J -f arg2 <=> -c arg1 -J -f arg2 arg0 (-c and -f in this example take arguments)
<al-maisan>
thelema: thanks for the pointer!
<thelema>
flux: of course it's the one I (co-)wrote, arg2.ml
<adrien>
-- is trivial to get compared to the compression of arguments
<flux>
my parser doesn't really handle the 'floating' argument (the one that doesn't have a switch for it)
<thelema>
flux: floating arguments seem best handled by just accepting a function to consume them
ttamttam has joined #ocaml
<adrien>
I made mine so that all arguments accept a list of "sub"-arguments: you parse, find an arguments, start looking for possible sub-arguments and if you find an argument that is not in the list of possible sub-arguments, you say it belongs to the parent level, pretty much recursion
<thelema>
adrien: eep
<flux>
thelema, in practice, I would most often like to get them as a list
<flux>
thelema, of course, one can collect them, but I'd rather the library do it for me ;-)
<flux>
I can then afterwards nicely pattern match the list
init1 has quit [Quit: Quitte]
ztfw has joined #ocaml
<thelema>
I guess the library could return a list when it's done parsing, and the collection function could be (string -> string option) so it could reject a value and instead put it on the list
<adrien>
I find that it's easier to have the library only return a list and let you check everything is like you want it to be
<thelema>
one thing I wanted to add to my library was a way to call a function on multiple arguments to handle one option with multiple parameters
<thelema>
(with default values)
<thelema>
right now I store the parsed parameters in ref cells, and call the function on those ref cells, but this is ugly
<thelema>
there's probably a nice way to do it in my parser, I thuink
<flux>
one problem with those parsers is that I'd like to get a record with my settings back
<flux>
but that basically forces the argument handler to be a folding function
<flux>
and the individual value changing functions are somewhat repetitive
<thelema>
yes, at least refs can be passed individually, you'd have to pass modifier functions for each record field
<flux>
after command line argument parsers I typically have this code: proceed { a = !a; b = !b; c = !c } etc
<flux>
and the 3.12 extension { a; b; c } doesn't help at all with this :)
<thelema>
one subtlety is that there's two lists of argument handlers, for mandatory and optional arguments. The optional arguments need to be paired with unit functions to be called if there's no rg present
avsm has quit [Quit: Leaving.]
jm_ocaml has joined #ocaml
ftrvxmtrx_ has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 276 seconds]
pdhborges has quit [Quit: pdhborges]
pikachuyann has joined #ocaml
pdhborges has joined #ocaml
pdhborges has quit [Quit: pdhborges]
mnabil_ has quit [Ping timeout: 272 seconds]
pdhborges has joined #ocaml
oriba has joined #ocaml
seafood_ has quit [Quit: seafood_]
Snark_ has joined #ocaml
Snark_ is now known as Snark
hto has joined #ocaml
<hcarty>
thelema: Has a direction for exception handling in future releases of Batteries been decided on? Exceptionless by default, exceptions by default with Exceptionless modules (like now), or provide both functions (foo and foo_opt or foo_exn depending on default) in the same module?
<thelema>
can't be exceptionless by default - backwards compatibility
<hcarty>
thelema: I didn't expect any changes on this front until 2.0
<thelema>
Exceptionless modules seems best to me, although we'll end up with top-level module explosion if we do (threads, no threads, threads exceptionless, nothreads exceptionless, + labeled variants (4))
<thelema>
backwards compatibility with stdlib
<hcarty>
Ah
myu2 has joined #ocaml
pikachuyann has quit [Remote host closed the connection]
pikachuyann has joined #ocaml
ttamttam has quit [Remote host closed the connection]
NaCl has joined #ocaml
* NaCl
pokes adrien
<adrien>
=)
* NaCl
may hang out here more
alpounet has joined #ocaml
<pdhborges>
Does anyone know of a C extension written in good style?
<pdhborges>
I'm following cryptokit but some parts are written in totally diferent styles
<adrien>
Unix from ocaml itself?
<adrien>
may I ask what you are binding btw?
<pdhborges>
zeromq
<thelema>
pdhborges: what do you need help with, writing C that interfaces with ocaml, linking, something else?
<pdhborges>
thelema: just the bindings style
<pdhborges>
some bindings use return
<pdhborges>
other use OCAMLreturn
<pdhborges>
other do not use OCAMLparams
<thelema>
then don't look at pycaml. unix is probably your best bet
<pdhborges>
a ok
<pdhborges>
:D
<pdhborges>
s/other/others
<thelema>
return vs. OCAMLreturn depends on whether that function allocates
<adrien>
I'd stay safe and always use the CAML* macros
<adrien>
basically, you need the macros in the general case but sometimes you can skip them, that "sometime" is hard to get exactly, it's easy to make a mistake, especially if your code is often changing
<pdhborges>
yeah
<pdhborges>
the unix lib
<pdhborges>
only returns longs and units
<pdhborges>
so it's not that good for inspiration
<pdhborges>
:\ I'm going to use the macros everywhere
<hcarty>
It has special targets for custom toplevels and lots of other goodies.
<pdhborges>
:|
<pdhborges>
I tried the first link but no go
khia0 has joined #ocaml
khia0 has left #ocaml []
<pdhborges>
Now I linked the cma statically
<pdhborges>
and I get caml_zmq_init
<pdhborges>
not available
<hcarty>
pdhborges: I recommend adrien's suggestion - OCamlMakefile
<hcarty>
Particularly during early development
<hcarty>
It includes a nice example of C bindings
<pdhborges>
I wnated to understand every step
<hcarty>
Example of compiling C bindings with OCamlMakefile, that is
<pdhborges>
:|
<pdhborges>
the example in the first page works
<pdhborges>
I'm making mistake somewhere
<hcarty>
pdhborges: I think it has a "verbose" option, which may help. But I understand wanting to know why things are or are not working.
<alpounet>
hey hcarty :)
<adrien>
pdhborges: you could use OCamlMakefile and see exactly what it does: since it's a makefile, it'll output each command called
<hcarty>
alpounet: Hello
<pdhborges>
adrien: I have the log of one oasis instalation
<alpounet>
what's up
<pdhborges>
(cryptkit)
<pdhborges>
grrr
<pdhborges>
I must be a retarded because I following every setep from the example (which works)
<pdhborges>
and with my bindings it doesn't woek
<oriba>
short question on ocamlnet... I used Http_client.Convenience for some web-get-retrievals... now I need to send a Referrer and maybe later handle Cookies
<oriba>
how to do that?
<oriba>
seems that the Convenient module does not offer such possibilities
<adrien>
I've always been under the impression that C bindings are heavily impacted by the current weather ;-)
<oriba>
but does ocamlnet offer it?
<oriba>
which module?
<adrien>
oriba: Http_client itself?
<hcarty>
oriba: ocurl maybe? I don't know about ocamlnet.