<_habnabit>
is there some way of allocating a bigarray wrapping memory that ocaml is managing from C?
<_habnabit>
alloc_bigarray seems to just wrap a pointer instead of copying its contents
tlockney has quit [Excess Flood]
tlockney has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
ulfdoz has joined #ocaml
NihilistDandy has joined #ocaml
KDr2 has joined #ocaml
mjonsson has joined #ocaml
NihilistDandy has quit []
KDr2 has quit [Ping timeout: 244 seconds]
KDr2 has joined #ocaml
bzzbzz has quit [Quit: leaving]
<malouin>
is there a godified http client?
<thelema>
malouin: netclient?
<malouin>
there is a netclient godi package?
twittard has quit [Quit: twittard]
<thelema>
malouin: godi-ocamlnet
letrec has joined #ocaml
Drup has quit [Quit: Leaving.]
oriba has quit [Quit: oriba]
<malouin>
I see.
<malouin>
already installed, even.
lamawithonel_ has joined #ocaml
lamawithonel has quit [Ping timeout: 276 seconds]
datkin has quit [Remote host closed the connection]
datkin has joined #ocaml
twittard has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
g0dmoney- has quit [Ping timeout: 246 seconds]
g0dmoney- has joined #ocaml
Tobu has joined #ocaml
lamawithonel__ has joined #ocaml
lamawithonel_ has quit [Ping timeout: 245 seconds]
codesnow has joined #ocaml
mjonsson has quit [Quit: Leaving]
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
codesnow has quit [Ping timeout: 260 seconds]
EmmanuelOga has quit [Quit: WeeChat 0.3.7-dev]
Kakadu has joined #ocaml
twittard has quit [Quit: twittard]
thelema has quit [Remote host closed the connection]
thelema_ has joined #ocaml
NihilistDandy has joined #ocaml
<adrien>
morning
edwin has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
ftrvxmtrx has joined #ocaml
Snark has joined #ocaml
letrec_ has joined #ocaml
letrec has quit [Ping timeout: 260 seconds]
Cyanure has joined #ocaml
avsm has joined #ocaml
wagle has quit [Remote host closed the connection]
wagle has joined #ocaml
Cyanure has quit [Ping timeout: 248 seconds]
MaskRay has quit [Remote host closed the connection]
avsm has quit [Quit: Leaving.]
Xizor has joined #ocaml
Cyanure has joined #ocaml
<iZsh>
thelema_: tiny suggestion for BatSet: a find: ('a -> bool) -> 'a t -> 'a function, and a "replace/add" function which add an elm, and replace the existing one if it already exists according to the cmp function provided at creation
pango is now known as pangoafk
ppilatus has quit [Remote host closed the connection]
jchillerup has joined #ocaml
<jchillerup>
Hi! I am pretty new to OCaml. I have a string in which I want to do a global_replace
<jchillerup>
I just can't seem to figure out the right syntax
Tobu has quit [Remote host closed the connection]
Tobu has joined #ocaml
<iZsh>
jchillerup: what do you want to replace with what?
pangoafk has quit [Ping timeout: 260 seconds]
avsm has joined #ocaml
Drup has joined #ocaml
NihilistDandy has quit []
Goldfish137 has joined #ocaml
<Goldfish137>
Hello
<Ptival>
hello
<Ptival>
jchillerup: do you have a problem with the matching regexp, or with the replace template?
Tobu has quit [Ping timeout: 260 seconds]
avsm has quit [Quit: Leaving.]
Tobu has joined #ocaml
<jchillerup>
iZsh: I want to replace ' with \'
<jchillerup>
And the string is already in a variable
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
<jchillerup>
radio = on_metadata(fun(meta) -> system("/usr/share/liquidsoap/log.py '"^ meta["filename"] ^"'"), radio);
<jchillerup>
I want to replace ticks in meta["filename"] with thier escaped counterparts
<iZsh>
try String.escaped then
<jchillerup>
like this: meta["filename"].excaped?
<jchillerup>
escaped*
<Ptival>
no
<Ptival>
String.escaped meta["filename"]
Drup has quit [Quit: Leaving.]
MaskRay has quit [Remote host closed the connection]
oriba has joined #ocaml
ikaros has joined #ocaml
<jchillerup>
Ah, thanks
<iZsh>
jchillerup: btw, you have a security bug
<iZsh>
oops, maybe that's why you were trying to escape it
<iZsh>
I wouldn't do it like that then
<iZsh>
use a whitelist, not a "blacklist"
silver has quit [Remote host closed the connection]
silver has joined #ocaml
Zedrikov has joined #ocaml
Xizor has quit []
<_habnabit>
or, even better, don't use system
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
Zedrikov has quit [Quit: Bye all, see you next time!]
antoineB has joined #ocaml
The_third_man has quit [Ping timeout: 240 seconds]
<antoineB>
hello, i am new to ocaml, and i don"t manage to create a Set (in the interactive ocaml)?
<_habnabit>
okay?
codesnow has joined #ocaml
<thelema_>
antoineB: module IntSet=Set.Make(struct type t = int let compare = compare end);;
<thelema_>
antoineB: let s = IntSet.singleton 5;;
<thelema_>
iZsh: BatSet.modify_def
<antoineB>
thelema_: thanks you
Submarine has quit [Ping timeout: 244 seconds]
pango has joined #ocaml
pango has quit [Quit: I'll be back]
codesnow has quit [Ping timeout: 265 seconds]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
oriba has quit [Quit: oriba]
milosn has quit [Read error: No route to host]
milosn has joined #ocaml
datkin has quit [Read error: Connection reset by peer]
kozikow has joined #ocaml
datkin has joined #ocaml
datkin_ has joined #ocaml
<kozikow>
Hello everyone
<kozikow>
I have strange problem, because it looks like my function is adding only one object to the list in each loop
<_habnabit>
- : string list = ["Hel"; "ell"; "llo"]
<Ptival>
you're mutating the closure
<kozikow>
Thanks _habnabit
<kozikow>
I am now trying to understand why it's working the way it is
<kozikow>
thanks everyone
<_habnabit>
we just told you: you have five of the same string in your list
<kozikow>
That's what I guessed
<kozikow>
But now I am trying to understand
<kozikow>
why is it so
<_habnabit>
apparently `let f () = let s = "foo" in s` will always give you the same string
<_habnabit>
# let f () = let s = "foo" in s in f () == f ();;
<_habnabit>
- : bool = true
<_habnabit>
yep
<kozikow>
Well it's good optimization from the point of compiler
<kozikow>
but shouldn't it guess that string is mutable?
<_habnabit>
personally I would prefer that compilers not 'guess' anything
<kozikow>
Is there a way of telling the compiller that I am planning to mutate the object?
<kozikow>
I tried adding ref "___"
<kozikow>
but it didn't help
<datkin>
Just do [String.copy];;
<datkin>
Or just [String.create 3]
<Ptival>
yes
<kozikow>
It works, thanks :)
<Ptival>
and it's not an optimization :)
<_habnabit>
ref does the opposite of what you want
<kozikow>
My guess was that compiler assumes that since this object will be allocated in each function call it allocates it on the first call and then if garbage collector doesn't collect the object it reuses it
<kozikow>
So if I would allocate array this way
<kozikow>
let's say let arr = [|2;3;4|] and then mutate it
<kozikow>
the effect would be the same?
<datkin>
The compiler doesn't do anything weird. This is the first line of the compiled function:
<datkin>
L1: const "___"
<kozikow>
If it's const, so why it allowed me to mutate it without the warning?
<_habnabit>
datkin, where do you get that output from?
<kozikow>
Is there a way to get readable output from ocaml compiler in anything else than assembler?
<datkin>
ocamlc -dinstr (so it's a bytecode instructions, not assembly instructions)
<datkin>
ocamlopt -S will give you the assembly though:
<datkin>
.ascii "___"
<datkin>
It just allocates the string somewhere in the data segment, and references that address every time you call the function.
<kozikow>
ocamlc -dinstr looks cool
<kozikow>
So, in my opinion, compiler should issue the warning
<kozikow>
That I am planning to mutate the thing, which was classified as const
<Ptival>
what warning?
<kozikow>
That we are mutating the const string
<datkin>
I think in this case "const" means something different than what you're thinking.
<Ptival>
yes
<datkin>
It means something along the lines of "allocate a string with this constant (statically-known) value"
<datkin>
And it only gets allocated once.
<Ptival>
I think so
<kozikow>
It's what it's doing, but imo it's still a quirk in language
<Ptival>
kozikow: String.set does in-place modification of a string. Your function is closed over the string, so you're actually modifying the string for all invocations of the function
<Ptival>
it is not supposed to be surprising
<Ptival>
adding "ref" means now you're closed on a reference to the string, so it doesn't solve the problem, just adds a level of indirection
<kozikow>
Yes, I know, but I say that it's counter-intuitive
<_habnabit>
programming is an unnatural act; nothing is 'intuitive'
brooksbp has quit [Quit: Leaving]
<kozikow>
I'm too used to C++
<kozikow>
Anyway, thanks for help everyone :)
<datkin>
Where to do something similar you would either allocate a new string everytime you call "triple" or you would allocate the string once outside of the function, and you would have the same problem.
<kozikow>
I would use string s = "aaa";
<kozikow>
which would call the constructor
<kozikow>
In every call and it's basically what I wanted.