<Unhammer>
does ocaml have an equivalent of python's 'if __name__ == "__main__"' ?
<Unhammer>
ie., "am I being run on my own or required into something else"
dav has quit [Ping timeout: 265 seconds]
dav has joined #ocaml
<dsheets>
Unhammer, top-level side effects are executed in link order. no official way exists to detect whether this module is the last in the link order, afaik. You can adopt a convention like checking Sys.argv.(0) against the name of the module as a string, though.
<Unhammer>
aha
<Unhammer>
ok, thanks
Ch0c0late has joined #ocaml
<dsheets>
Unhammer, might want to use Filename.basename in conjunction to get the name of the executable... but it won't guarantee that multiple "main" initializers don't fire
<dsheets>
usually people separate their libraries from their command interfaces at the module level and then this kind of dynamic check is not necessary
psy has joined #ocaml
Ch0c0late has quit [Client Quit]
bytbox has quit [Remote host closed the connection]
dav has quit [Ping timeout: 255 seconds]
yomimono has quit [Ping timeout: 256 seconds]
shinnya has quit [Ping timeout: 240 seconds]
demonimin_ has joined #ocaml
hausdorff has joined #ocaml
hausdorff has quit [Remote host closed the connection]
WraithM has joined #ocaml
hausdorff has joined #ocaml
demonimin has quit [Ping timeout: 264 seconds]
WraithM has quit [Client Quit]
zpe has joined #ocaml
BitPuffin has quit [Read error: Connection reset by peer]
<kaustuv>
It's probably too late to change this now, but why is it that Format.pp_print_cut etc. have type formatter -> unit -> unit and not formatter -> unit?
<companion_cube>
I suppose it's to be used with %t
<Drup>
Because formaters are, in general, of the form "formatter -> 'a -> unit"
hugomg has joined #ocaml
ysz_ has quit [Remote host closed the connection]
diethyl has joined #ocaml
serge has quit [Remote host closed the connection]
leowzukw has joined #ocaml
dav has joined #ocaml
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
<kaustuv>
companion_cube: that makes no sense.
<kaustuv>
# Format.printf "%t" ;;
<kaustuv>
- : (Format.formatter -> unit) -> unit = <fun>
diethyl has quit [Ping timeout: 250 seconds]
<kaustuv>
Drup: that's a pretty tautological reason as I see it
<Drup>
kaustuv: well, look at all the functions starting by pp_print_
<Drup>
I didn't say it was a good choice, I just gave you a reason :)
<kaustuv>
Yes, I know what you meant. I am questioning the conformance to some schema for the sake of conformance
_5kg has quit [Ping timeout: 260 seconds]
elfring has joined #ocaml
<Drup>
well, consistence here is useful, since the major good point of formatters is easy composition.
nicoo has quit [Write error: Broken pipe]
_5kg has joined #ocaml
leowzukw has quit [Quit: leaving]
chambart has quit [Ping timeout: 244 seconds]
BitPuffin has joined #ocaml
nicoo has joined #ocaml
jwatzman|work has joined #ocaml
larhat has joined #ocaml
olauzon has joined #ocaml
arj has quit [Quit: Leaving.]
elfring has quit [Quit: Konversation terminated!]
ysz_ has joined #ocaml
ysz_ has quit [Remote host closed the connection]
olauzon has quit [Quit: olauzon]
olauzon has joined #ocaml
olauzon has quit [Client Quit]
olauzon has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
<companion_cube>
kaustuv: oh.
oscar_toro has quit [Ping timeout: 265 seconds]
psy has quit [Disconnected by services]
zpe has quit [Remote host closed the connection]
psy_ has joined #ocaml
zpe has joined #ocaml
mcclurmc has joined #ocaml
marynate has quit [Quit: Leaving]
zpe has quit [Ping timeout: 250 seconds]
WraithM has joined #ocaml
c74d has quit [Read error: Connection reset by peer]
c74d has joined #ocaml
kakadu has quit [Quit: Page closed]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
yomimono has joined #ocaml
dav has quit [Ping timeout: 265 seconds]
dav has joined #ocaml
Thooms has quit [Quit: WeeChat 1.0.1]
<Drup>
whitequark: did you tested how compatible ppx_deriving was with deriving ?
<Drup>
compatible as in "code generated by show from one can be used by the other"
olauzon has quit [Ping timeout: 260 seconds]
kakadu has joined #ocaml
zpe has joined #ocaml
bytbox has joined #ocaml
bytbox has quit [Remote host closed the connection]
serge has joined #ocaml
<Unhammer>
dsheets, yeah several files sounds like a better solution
serge has quit [Ping timeout: 244 seconds]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
dav has quit [Ping timeout: 256 seconds]
BitPuffin has quit [Read error: Connection reset by peer]
dsheets has quit [Ping timeout: 255 seconds]
slash^ has joined #ocaml
thomasga has quit [Ping timeout: 265 seconds]
rjmacready_ has quit [Quit: Page closed]
dav has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
mcclurmc has quit [Remote host closed the connection]
MrScout has joined #ocaml
olauzon has joined #ocaml
olauzon has quit [Client Quit]
olauzon has joined #ocaml
olauzon has quit [Client Quit]
thomasga has joined #ocaml
koderok has quit [Quit: koderok]
slash^ has quit [Ping timeout: 272 seconds]
<whitequark>
Drup: nope! I have not even ran deriving once
<Drup>
ok
mcclurmc has joined #ocaml
dav has quit [Ping timeout: 265 seconds]
dav has joined #ocaml
olauzon has joined #ocaml
ljs has joined #ocaml
claudiuc has joined #ocaml
olauzon has quit [Client Quit]
<ljs>
Hey there, I have a question about how to use mutations wisely. Suppose in a server program, I want to store incoming clients information. I always use Hashtbl in this case. When I want to iterate through the hashtbl, I am not sure if the iteration order will always be the same. So I am thinking to use a list, which can give me stable iteration orders. However, ocaml does not
<ljs>
have mutation List....I am wondering what is the typical way to deal with this?
govg has quit [Ping timeout: 245 seconds]
<adrien>
'a ref list ?
<ggole>
Or a queue
<adrien>
also, if your hashtable keys are provided by the client, you risk a DoS
* adrien
looks at nicoo
<ljs>
will defining (clients : list ref) result in inefficiency implementation?
dav has quit [Ping timeout: 245 seconds]
<ljs>
Let's simplify the case and don't take security into account.
<adrien>
queue is better than 'a list ref
dav has joined #ocaml
<ljs>
I found the similiar question ocurrs again and again.
<ljs>
OK
<adrien>
and it depends on the operation you're going to do
<adrien>
lookup in a queue is going to be really slow
<adrien>
and I guess you use that
elfring has joined #ocaml
<ggole>
Queue is suitable if you just put them in and take them out in order.
<ljs>
right
yomimono has quit [Ping timeout: 264 seconds]
<adrien>
from my really-tired-brain it sounds like Map would be the best fit
olauzon has joined #ocaml
<ljs>
but Map is immutable righ
<ggole>
If you want that but in the reverse order, there's stack (which is essentially what 'a list ref is, really).
<ljs>
right?
<ggole>
Yes, but you can use refs to update it in the same way as lists.
slash^ has joined #ocaml
<ggole>
The problem with Map is that order will depend on the structure of the keys, not of insertions.
<ggole>
*not the order of
<adrien>
as expected I had misunderstood things a bit :)
olauzon has quit [Client Quit]
<ljs>
Sure
<Drup>
ljs: which operation do you want ? iteration on the order of arival and lookup ?
<ljs>
either hashtbl, or list ref.
hausdorff has quit [Remote host closed the connection]
<Drup>
"ljs: right, select the nth one based on the order print out on the screen."
Thooms has joined #ocaml
<ljs>
yes, this one
<Drup>
ljs: the nth, I don't really know
<ljs>
it is not slash msg...
<Drup>
are you sure you want the nth, and not either discard message as they are handled or use the real date ?
<ljs>
Drup: Thanks.
<ljs>
Drup: I just want to simple command line to do operation on that client. Say I can list all the connected clients, and then select nth to do the operation.
<ljs>
Drup: I now think efficiency is not import at all, because this opeartion is rare
<Drup>
then Queue.
<ljs>
Right. Queue sounds good. Thanks!
zpe has joined #ocaml
yomimono has joined #ocaml
olauzon has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
olauzon has quit [Client Quit]
olauzon has joined #ocaml
dav has quit [Remote host closed the connection]
Guest42099 has joined #ocaml
bytbox has joined #ocaml
ljs has quit [Read error: Connection reset by peer]
ljs_ has joined #ocaml
ljs_ has quit [Read error: Connection reset by peer]
ljs__ has joined #ocaml
manud has joined #ocaml
Guest42099 has quit [Ping timeout: 258 seconds]
dav_ has joined #ocaml
Anarchos has joined #ocaml
serge has joined #ocaml
badkins_ has joined #ocaml
serge has quit [Ping timeout: 255 seconds]
badkins has quit [Ping timeout: 265 seconds]
_andre has quit [Quit: leaving]
slash^ has quit [Read error: Connection reset by peer]
jc2 has joined #ocaml
ollehar has joined #ocaml
jc2 has quit [Client Quit]
ggole has quit []
<reynir>
ocamltter is weird
<Drup>
why ?
<whitequark>
it doesn't really work
<Drup>
that's an important issue. =')
<companion_cube>
:D
<reynir>
there's a binary that seems to sort of work. All it seems to do is get tweets in japanese and read it out loud.
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
oscar_toro has joined #ocaml
manud has quit [Quit: manud]
ljs__ has quit [Ping timeout: 264 seconds]
ljs__ has joined #ocaml
ysz_ has joined #ocaml
<nicoo>
reynir: <3
<nicoo>
How you never dreamed of listening to Japanese tweets ?
MrScout_ has joined #ocaml
dav_ has quit [Remote host closed the connection]
<reynir>
I can't say I have, but it was quite an experience :)
hhugo1 has joined #ocaml
olauzon has quit [Ping timeout: 256 seconds]
olauzon has joined #ocaml
MrScout has quit [Ping timeout: 265 seconds]
manud has joined #ocaml
Guest23677 has joined #ocaml
MrScout_ has quit [Ping timeout: 265 seconds]
hausdorff has joined #ocaml
MrScout has joined #ocaml
dsheets has joined #ocaml
yomimono has quit [Ping timeout: 240 seconds]
ljs__ has quit [Quit: Be back later ...]
ljs__ has joined #ocaml
ljs__ has quit [Ping timeout: 245 seconds]
ljs___ has joined #ocaml
manud has quit [Quit: manud]
oscar_toro has quit [Ping timeout: 244 seconds]
Levenshtein_ has left #ocaml [#ocaml]
ljs___ has quit [Quit: Be back later ...]
dsheets has quit [Ping timeout: 264 seconds]
badkins_ is now known as badkins
ljs___ has joined #ocaml
ljs___ has quit [Client Quit]
MrScout has quit [Remote host closed the connection]
hausdorff has quit [Remote host closed the connection]
hhugo1 has quit [Quit: Leaving.]
serge has joined #ocaml
bytbox has quit [Remote host closed the connection]
serge has quit [Ping timeout: 272 seconds]
ollehar has quit [Ping timeout: 256 seconds]
MrScout has joined #ocaml
MrScout has joined #ocaml
MrScout has quit [Remote host closed the connection]
luzie has quit [Read error: Connection reset by peer]
<ysz_>
naive one
<ysz_>
i'm trying to build ocaml-ctypes-inverted-stubs-example
<ysz_>
and i got ld: ....opam/4.02.0/lib/ocaml/libasmrun.a(startup.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
<ysz_>
i got my ocaml with opam.
<ysz_>
should i now re-compile ocaml myself? :)
<ysz_>
(im on x86_64 obviously. Linux)
Guest23677 has quit [Ping timeout: 245 seconds]
ollehar has joined #ocaml
xaimus has quit [Ping timeout: 265 seconds]
dav has joined #ocaml
ljs___ has joined #ocaml
jonludlam has quit [Quit: Coyote finally caught me]
olauzon has quit [Quit: olauzon]
manud has joined #ocaml
hhugo1 has joined #ocaml
<thomasga>
ysz_: opam switch -a | grep PIC
<thomasga>
(not sure that's the quickest way to solve your problem though)
elfring has quit [Quit: Konversation terminated!]
bytbox has joined #ocaml
ollehar has quit [Ping timeout: 265 seconds]
hausdorff has joined #ocaml
waneck has joined #ocaml
nojb has joined #ocaml
struktured has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 264 seconds]
bytbox has quit [Ping timeout: 255 seconds]
ysz_ has quit [Ping timeout: 256 seconds]
Submarine has joined #ocaml
thomasga has quit [Quit: Leaving.]
shinnya has joined #ocaml
jonludlam has joined #ocaml
nojb has quit [Quit: nojb]
sheijk has joined #ocaml
manud has quit [Quit: manud]
hugomg has quit [Ping timeout: 245 seconds]
MrScout has joined #ocaml
MrScout has joined #ocaml
manud has joined #ocaml
ebzzry has quit [Read error: Connection reset by peer]
ebzzry_ has joined #ocaml
ljs___ has quit [Quit: Be back later ...]
manud has quit [Quit: manud]
serge has joined #ocaml
MrScout has quit [Remote host closed the connection]
bytbox has joined #ocaml
serge has quit [Ping timeout: 250 seconds]
BitPuffin has joined #ocaml
Thooms has quit [Quit: WeeChat 1.0.1]
Simn has quit [Quit: Leaving]
hausdorff has quit [Remote host closed the connection]