lapinou changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | http://www.ocaml.org | OCaml 4.01.0 announce at http://bit.ly/1851A3R | Public logs at http://tunes.org/~nef/logs/ocaml/
sorethroat has joined #ocaml
tobiasBora has quit [Quit: Konversation terminated!]
ygrek has joined #ocaml
sorethroat has quit [Read error: Operation timed out]
Simn has quit [Quit: Leaving]
watermind has quit [Quit: Konversation terminated!]
watermind has joined #ocaml
watermind has quit [Client Quit]
watermind has joined #ocaml
struktured has joined #ocaml
knulp has joined #ocaml
wolfnn has quit [Ping timeout: 260 seconds]
knulp has quit [Client Quit]
rom1504 has quit [Ping timeout: 272 seconds]
sorethroat has joined #ocaml
rom1504 has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
sorethroat has quit [Ping timeout: 250 seconds]
kyrylo has quit [Read error: Operation timed out]
dsheets_ has quit [Read error: Connection reset by peer]
ollehar has quit [Ping timeout: 246 seconds]
livewire1 has quit [Quit: WeeChat 0.4.2]
pkrnj has joined #ocaml
watermind has quit [Quit: Konversation terminated!]
ygrek has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
codygman has quit [Remote host closed the connection]
keithflower has quit [Quit: keithflower]
Don_Pellegrino has quit [Quit: Konversation terminated!]
struktured has quit [Ping timeout: 272 seconds]
ggole has joined #ocaml
lostcuaz has joined #ocaml
ygrek has quit [Ping timeout: 272 seconds]
struktured has joined #ocaml
struktured has left #ocaml []
yacks has joined #ocaml
the-gibson has joined #ocaml
Kakadu has joined #ocaml
axiles has joined #ocaml
jao has quit [Ping timeout: 248 seconds]
pkrnj has quit [Quit: Computer has gone to sleep.]
pkrnj has joined #ocaml
r0b has joined #ocaml
r0b is now known as rob1
rob1 is now known as r0b1
r0b1 has quit [Client Quit]
r0b1 has joined #ocaml
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
samebchase has quit [Ping timeout: 252 seconds]
samebchase has joined #ocaml
tianon has quit [Ping timeout: 264 seconds]
tianon has joined #ocaml
xaimus has quit [Ping timeout: 246 seconds]
xaimus has joined #ocaml
philtor has quit [Ping timeout: 245 seconds]
sorethroat has joined #ocaml
tianon has quit [Read error: Operation timed out]
mreca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vpm has quit [Remote host closed the connection]
tianon has joined #ocaml
ulfdoz has joined #ocaml
vpm has joined #ocaml
pkrnj has quit [Quit: Textual IRC Client: www.textualapp.com]
yacks has quit [Quit: Leaving]
FreeArtMan has joined #ocaml
sorethroat has quit [Ping timeout: 246 seconds]
mort___ has joined #ocaml
ygrek has joined #ocaml
arj has joined #ocaml
knulp has joined #ocaml
nilton has quit [Ping timeout: 272 seconds]
knulp has quit [Client Quit]
mort___ has quit [Quit: Leaving.]
cdidd has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 248 seconds]
<flux> has someone bumped into this problem? lablgtk2 widget (drawing area) resizes ok, but when I keep continuosly refreshing it, it won't anymore? however, other events work fine, such as highlighting/pressing buttons
<flux> hmm, could it be that my expose events are somehow higher priority than other events?
<flux> I issue the redraw with drawing_area#misc#draw None - maybe if I moved this to the idle mode?
sagotch has joined #ocaml
<adrien> refreshing it? through realize?
<adrien> hmmm, don't remember the name well
<adrien> in any case there is a dedicated method you put a callback on
cdidd has joined #ocaml
cdidd has quit [Remote host closed the connection]
<flux> I have hooked the expose event to do my drawing
<flux> and it's in my event list, and that works fine
<flux> but when it gets many frames per second, my resize events don't seem to go through to the drawing_area
<adrien> right that was expose I had in mind; as for your specific issue, I don't know
<adrien> do you have a small reproducer?
<flux> no small one, not at least yet..
<adrien> I haven't played with drawing areas for a couple years but I don't think I had many issues with it
Simn has joined #ocaml
<flux> interesting thing I noticed.. if I don't call drawing_area#misc#draw at all, the quit button doesn't get drawn either :-o
<flux> but the button is there, I can press it
<adrien> :P
<flux> ah, if I don't draw it it apparently starves even worse to my IO events
<adrien> hmm
<adrien> you have several threads?
<flux> no, only one thread
<adrien> is there a lot of work to do during an expose event?
<flux> well, there is some. it makes a 640x480 cairo surface and blits an image to it.
<flux> but overall it takes 30% cpu
<flux> the whole program
<adrien> (there's also latency that can have an impact)
<adrien> well, I need to see the code and try it on my computer
<flux> do you have a webcam?-)
<adrien> obviously
<adrien> the actual question is: can you use it? :P
<adrien> I might have stopped building the drivers after some flash object on a page activated the webcam
julm has quit [Ping timeout: 252 seconds]
arj has quit [Quit: Leaving.]
julm has joined #ocaml
pminten has joined #ocaml
<flux> got it working
<flux> I changed it from this: GMain.Io.add_watch-callback -> get image from webcam -> call drawing_area#misc#draw None to this: GMain.Io.add_watch-callback -> disable callback -> add an idle event that gets the image and calls drawing_area#misc#draw None and enabled io-callback
Anarchos has joined #ocaml
<flux> (I wonder if that was very clear..)
<adrien> it was, at least to me
cdidd has joined #ocaml
<flux> though I probably have a bug somewhere
<flux> it takes 100% cpu now :)
<adrien> if I've understood correctly: don't give more work to your application while it's already working
<adrien> and you should maybe thread that, either through system threads or lwt
<flux> how do lablgtk and threads play together?
<adrien> you put the I/O watch in a separate thread and only use it to retrieve the image
<adrien> they play well; you can read
<flux> how about sending expose events from other threads?
<adrien> several platforms won't let you draw from different threads
<flux> ah, those two functions should make me feel safe :)
<adrien> and for gdk you need to first acquire a lock so that different threads don't use the gdk stuff at the same time
<flux> it might actually genuinely need 100% cpu now, because perf says most of the time is spent in caml_ba_get_N, which I do a whole lot
<adrien> as far as I'm concerned, I'd really only use a separate thread for the image retrieval
<adrien> :)
<adrien> (-unsafe)
dant3 has joined #ocaml
dant3 has quit [Remote host closed the connection]
<flux> ok, now I'm probably there. while caml_ba_get_N is still at top, the close second one is a C function rgb_of_yuv..
<adrien> feels wrong to me; getting the data should be fast
<flux> I'm not quite sure where the function is being called from, perf cannot see ocaml backtrace
<flux> gprof says 'spontaneous' :)
<adrien> you build with -g too? and maybe blit but that should be a fast operation (unless maybe you read in the wrong dimension)
<flux> I replaced manual copying of 3 bytes with Bigarray.Array1.blit, now I have some libc symbol __mcount_internal on top..
<flux> I'll add an FPS counter so I know it's not because of some obscene number of frames :)
<adrien> :)
<flux> well, 28 FPS doesn't sound too high
ollehar has joined #ocaml
dant3 has joined #ocaml
<sagotch> hi. speaking about graphicsm is there any special problem with the built-in graphics library? performance? reliability?
<adrien> performance is good, reliability is good too
<adrien> prettiness though...
<adrien> Graphics is easy to describe: 2D raster graphics with keyboard and mouse events
<adrien> you get nothing less, nothing more
<adrien> (and it has double-buffering
<adrien> )
mort___ has joined #ocaml
<Anarchos> adrien is it in ocaml ?
mort___ has quit [Client Quit]
mort___ has joined #ocaml
<adrien> Anarchos: what? Graphics?
<Anarchos> adrien sorry i just get the conversation into the middle
<adrien> Anarchos: well, Graphics is a module in the stdlib
<adrien> (well, the "otherlibs" part but it comes with ocaml)
<sagotch> then, the only issue with graphics is the look, I did not know if it was a kind of poor man's implementation
<adrien> 2D raster graphics, no anti-aliasing and basic features
<adrien> depending on what you want to do it can be enough
<Anarchos> adrien but you need nothing more to build upon of it !
<adrien> oh, you do
<flux> adrien, got it "down to" 70% by eliminating a redundant ba->string->ba
<flux> good enough for me :)
<adrien> ah :)
<adrien> well, real-time now :)
<adrien> 30FPS?
<flux> 29.94
<adrien> heheh :)
<Anarchos> flux in which program ?
kyrylo has joined #ocaml
ygrek has joined #ocaml
<troydm> how do i specify null character ?
<troydm> i've tried '' and '\0'
<troydm> but they don't work
<flux> anarchos, a program I wrote for viewing a webcam
<flux> gtk+v4l2
<flux> though kakadu's qt bindings are not out of question either :)
<Anarchos> flux ok ; what is v4l2 ?
<flux> Video4Linux2
<Anarchos> flux and 29.94 FPS is sufficient (as 24 images per second in cinema ?)
<flux> I think it's what I get from the camera
<flux> it looks very smooth
<flux> the final goal would be to interact with a CNC, and usually those programs seem to deviate from standard user interface concepts, ie. a great fit for QtQuick..
<flux> actually the webcam in question is a cheap china microscope
<flux> the next goal would be to write a program that can be used as follows: 1) drill a hole with CNC 2) find the location with the camera attached to the drill 3) now we can point'n click from the webcam view to choose places to cut
<flux> and the next goal after that would be saying 'this point is 0,0 and this point is 100, 0, translate the existing CNC program so that it uses this mapping"
ohama has quit [Ping timeout: 250 seconds]
<adrien> troydm: '\000'
<troydm> adrien: ah, thx
<adrien> troydm: just checking though: why do you need one?
<troydm> adrien: did u found out that using Char.chr(0)
<troydm> ?
<adrien> no, it's because you need 3 digits
<troydm> adrien: why three digits?
<adrien> because :P
<adrien> it's just something set into the language
<adrien> Anarchos: 29.94 is also a specific frame-rate ;-)
<adrien> 30 is only an approximation of 29.94 when it comes to video
<adrien> flux: you can play with ocaml-efl too now ;p
<flux> troydm, let's say you wanted the letter 0 after a ascii zero. would it be "\00"? ocaml doesn't like ambiguity :)
grantp has joined #ocaml
<troydm> flux: why not '\0' ?
<adrien> because there is \123 too
<adrien> note that you also have 0o123 for octal
<adrien> and 0xFF for hex
<troydm> hmm, ic
<grantp> Hi, all. I'd like to use ocamlmktop to create a custom toplevel with compiler-libs pre-loaded. This way I could run my custom toplevel and execute `open Toploop;;' without error. (Note that I can do this without a custom toploop via `ocaml -I +compiler-libs'). The following command creates a toplevel where compiler-libs isn't available. Will you please advise? ocamlfind ocamlmktop -o toploop -package compiler-libs -linkpkg -custom
sagotch has quit [Remote host closed the connection]
<adrien> your command truncated after "-custom"
<adrien> messages on IRC are limited to 512o (roughly)
<grantp> Hi, adien - that's actually the end of my command
<grantp> *adrien
<adrien> heh :)
cdidd has quit [Read error: Connection reset by peer]
<grantp> Hmm, so no glaring mistake? :-)
<adrien> well, the module would probably require you to use -package compiler-libs.toplevel
<adrien> because Toploop is inside ocamltoplevel.cma which is only pulled by the "toplevel" subpackage of "compiler-libs"
<adrien> ("compiler-libs" alone doesn't seem to pull any library)
<adrien> however I can't get it to work
ohama has joined #ocaml
<adrien> but actually, I'd tend to believe that that module is already available
<adrien> why do you want to create a toplevel specifically
<adrien> ?
<adrien> #use "topfind";;
<adrien> #require "compiler-libs.toplevel";;
<adrien> open Toploop;;
<adrien> that works for me
<grantp> Ah interesting, thank you. It doesn't for me - I get `unbound module Toploop'
<grantp> (4.01.0)
<grantp> But, if I create a toploop with findlib: ocamlfind ocamlmktop -o toploop -package findlib -linkpkg -custom
<adrien> hmm, I'm on some weird version between 4.01 and 4.02 here
<grantp> Then, #require "compiler-libs";; open Toploop;; works
<grantp> Hmm, I'll keep digging. Thank you.
mort___ has quit [Quit: Leaving.]
mort___ has joined #ocaml
cdidd has joined #ocaml
bnwr has left #ocaml []
pminten has quit [Quit: Leaving]
ygrek has quit [Ping timeout: 245 seconds]
Thooms has joined #ocaml
Anarchos has quit [Quit: rebooting]
grantp has quit [Quit: Page closed]
lopho has quit [Ping timeout: 276 seconds]
lopho has joined #ocaml
yacks has joined #ocaml
ontologiae has joined #ocaml
skchrko has quit [Remote host closed the connection]
Yoric has joined #ocaml
wolfnn has joined #ocaml
Yoric has quit [Ping timeout: 265 seconds]
Anarchos has joined #ocaml
ontologiae has quit [Ping timeout: 265 seconds]
reader9 has joined #ocaml
<reader9> I'm learning OCaml, and have come across a pattern matching I do not understand.
<Anarchos> reader9 is it a oneliner or do you need to pastebin it ?
<reader9> In the context of this code, the value str_desc is already defined
<reader9> Anarchos: just a one-liner, thank you
<Anarchos> reader9 ok let me see it then
<reader9> this line is used to define lst, and I don't understand how:
<reader9> let Typedtree.Tstr_value (_, lst) = str_desc in
<troydm> what's ocaml equivalent to haskell's $
<troydm> ?
<Anarchos> reader9 you have to use "function" or "match" keywords to introduce pattern matching.
<reader9> PS Anarchos, in case it's helpful, here is the full example: https://gist.github.com/jsyeo/7151426
<reader9> That line I pasted is defining the value of lst
<reader9> Yet I don't understand how.
<Anarchos> let me look
<reader9> Thank you very much
<Anarchos> what is the error message ?
<reader9> No error - it works perfectly
<reader9> I'm just trying to understand the code
ygrek has joined #ocaml
<Anarchos> it matches str_desc with a construction of the shape Typedtree.Tstr_value (_, lst) , ignoring the first argument with the wildcard «_»
<Anarchos> and create a variable named lst with the second argument
<reader9> Oh, so Typedtree.Tstr_value is a constructor of a sum type?
<reader9> I was thinking it was a function
<reader9> which is why I was confused!
<Anarchos> reader9 yes : Typedtree is a module
<Anarchos> so Tstr_value must be a constructor
<Anarchos> within that module
darkf has quit [Quit: Leaving]
<reader9> Got it - so str_desc is a value of the form Typedtree.Tstr_value (x, y), and we're just extracting the y component as lst
<Anarchos> yes that's it !
<reader9> Amazing, thank you!
mort___ has quit [Quit: Leaving.]
<reader9> BTW, is there a canonical goto resource on the web for finding the OCaml source code? If I Google `Typedtree OCaml module,' I get many hits, and I'm not sure if there's a best place to start for looking for the `official' source code for OCaml 4.01.0, for instance
<Anarchos> reader9 wam
<reader9> Perfect, thank you. BTW, what is `wam' (other than Warren Abstract Machine?) :-)
<Anarchos> wait a minute :)
<reader9> Haha, great, thank you :-)
tane has joined #ocaml
tane has quit [Remote host closed the connection]
tane has joined #ocaml
<troydm> adrien: what's ocaml's equivalent of haskell's $ operator ?
Arsenik has joined #ocaml
<Anarchos> troydm what does the haskell $ operator do ?
<troydm> Anarchos: well something like f (g h) can be rewritten to f $ g h
<troydm> like instead of writing raise (My_exception "error message")
<Anarchos> just write f (g h)
<troydm> Anarchos: heh :)
kamatara has joined #ocaml
<Anarchos> i think there is a new operator, but honestly, parentheses in this case are the more understood by most of people !
kamatara has quit [Client Quit]
<bernardofpc> well, if you want to passs f $ g as an argument to a function, it's best not to have to write (fun h -> f(g h))
zzaz has joined #ocaml
watermind has joined #ocaml
<zzaz> Hello, I'm new to functional programming and OCaml
<zzaz> I'm going through "Introduction to Objective Caml" by Jason Hickey
<zzaz> I'm stuck on an exercise though and I don't like skipping exercises
<zzaz> here it is: http://imgur.com/a/FCinh
<zzaz> I've managed to solve the first part correctly I believe
<zzaz> but I'm not sure how to approach the second part, the integral function that is
<zzaz> I'd really appreciate some hints
<bernardofpc> adrien: do you know how to track a "mouse_down" so that every time it changes pixel I can redraw the object ?
<bernardofpc> (to make "dragging" of a shape in a pixmap)
<bernardofpc> (it's a shame that lablgtk tutorial is soooooooooooooooooooooooo slow to get :/)
<bernardofpc> (each page takes ages to load here)
kamatara has joined #ocaml
<bernardofpc> zzaz: what's your definition of -| ??
Yoric has joined #ocaml
<zzaz> bernardofpc: let (-|) s1 s2 = (fun i -> s1 i - s2 i);;
<bernardofpc> ok
<bernardofpc> what should be (integral s)(0), (integral s)(1) and (integral s)(2) ?
<zzaz> 0 + c, 1 + c, 2 + c?
<bernardofpc> who is s ?
<zzaz> let s i = i;;
<bernardofpc> ok
<bernardofpc> the sequence of naturals, then
<zzaz> yes
<bernardofpc> your 3rd term should be 3 +c, right ?
<zzaz> 0 is the first one, so the 3rd would be 2 + c
<zzaz> so not naturals actually
<zzaz> sequence of non-negative numbers
<bernardofpc> your stream is 0, 1, 2, 3, ...
<bernardofpc> it's integral is 0, 1, 3, 6, ..., right ?
<bernardofpc> (don't ever argue about 0 being positive/natural/whatever in the internets ;-))
<zzaz> I'll keep that in mind
<kamatara> 0 is not positive
<bernardofpc> let's keep to programming :D
<bernardofpc> do you see the reason for 1,3,6,10 ?
<bernardofpc> (by the way, you should have a function print_s s = List.map s [0;1;2;3;4;5;6;7;8;9]
<bernardofpc> that will "print" the first 10 values of your stream in the REPL, it helps seeing if everything is allright)
<zzaz> bernardofpc: could you explain 1,3,6,10?
Eyyub has joined #ocaml
<bernardofpc> sure
<bernardofpc> but before that
<bernardofpc> did you ever hear about derivativs /integrals in math before ?
<zzaz> yes, not applied to streams though
<bernardofpc> right
<bernardofpc> so this stuff is like the "discrete" version of derivatives and integrals
<bernardofpc> which have much better names as "difference" and "cumulative sum"
<bernardofpc> in the same way that derivatif (integral f) = f, we want difference (cumulativesum f) = f
<bernardofpc> (the fact that you get a constant when you do the operations in the reverse order is a minor nuisance)
<bernardofpc> so what's the difference of your stream (0,1,2,3,4,...) ?
<zzaz> 1,1,1,1...
<zzaz> right?
pminten has joined #ocaml
pango has quit [Quit: Client exiting]
rython has joined #ocaml
mort___ has joined #ocaml
Yoric has quit [Ping timeout: 265 seconds]
rython has left #ocaml []
<bernardofpc> right
<bernardofpc> zzaz: then if your stream is 0,1,3,6,10,15, ... what's the difference ?
<zzaz> (1,2,3,4,...)
<bernardofpc> exact
<bernardofpc> now, let's do the opposite
<bernardofpc> if your strem is 1,1,2,2,3,3, what's the stream you have to construct such that it's differences is your original stream ?
<bernardofpc> (sorry for the ugly wording)
<adrien> troydm: there's an equivalent to haskell's $ in ocaml but I don't remember what it is :P (it's a fairly recent addition to the standard library)
<troydm> adrien: ic, thx, i'll look it up then
<adrien> bernardofpc: still wondering for the mouse position stuff?
<adrien> troydm: I'm surprised noone else answered though
<adrien> need to shake the channel a bit I guess
<bernardofpc> adrien: still ;-)
<bernardofpc> adrien: $ == @@ in OCaml
<adrien> (hmm, thought there was something else)
<zzaz> bernardofpc: sorry for delay, (1,2,3,5,7,10...)
<bernardofpc> rigth
<bernardofpc> how did you calculate that ?
<troydm> bernardofpc: it says @@ is not defined :(
<bernardofpc> troydm: it's called (@@) if you want to see its type
<bernardofpc> (in the toplevel)
<bernardofpc> (and only on "recent" OCaml, as far as I know)
<zzaz> I needed a sequence whose 2nd element minus the 1st one would be 1, the 3rd minus the 2nd one would be 1 and so on
<bernardofpc> how did you choose the 1st element ?
<adrien> bernardofpc: GObj -> event_signals -> motion_notify
<adrien> so
<troydm> bernardofpc: 4.01?
<troydm> bernardofpc: hmm i have 4.00.1 only
<adrien> button#motion_notify
<bernardofpc> oh
<adrien> almost
<zzaz> bernardofpc: randomly I guess, it would also work with a different element
<zzaz> (2,3,4,6,8,11,...)
<bernardofpc> right
<bernardofpc> so the first thing in your integral function is to decide your starting value, right ?
<adrien> bernardofpc:
<adrien> # b#event#connect#motion_notify;;
<adrien> - : callback:(GdkEvent.Motion.t -> bool) -> GtkSignal.id = <fun>
<zzaz> yes
<bernardofpc> adrien: many thanks !
<adrien> yw
<bernardofpc> can this be the same function as the one for #button_press ?
<bernardofpc> (anyway, I'll be lazy and try that first :D)
<bernardofpc> how do you do that ?
<reader9> Is there a standard OCaml library for providing a nicer version of input_line with, e.g., arrow key support for editing?
<bernardofpc> (for zzaz)
<adrien> bernardofpc: yes, it is
<adrien> reader9: rlwrap or another one which name I've forgotten...
<adrien> (rlwrap isn't really a lib)
<reader9> adrien: thank you - will look into rlwrap. I'm also trying to find out what utop uses, but haven't found it yet by browsing the source
<adrien> and
<reader9> amazing, thank you!
<adrien> you're welcome
<bernardofpc> adrien: seems not, one function needs "GdkEvent.Button.t" and the other "GdkEvent.Motion.t" and they have no intersection
mort___ has quit [Quit: Leaving.]
<adrien> ah, sorry, I had misunderstood your question
<bernardofpc> no pb ;-)
<bernardofpc> I'll factor out the common stuff and have one and the other grab x,y+buttonclicked
reader9 has quit [Ping timeout: 245 seconds]
<bernardofpc> This expression has type [> `MOTION_NOTIFY ] but an expression was expected of type Gdk.Tags.event_mask -> is there a way to capture them ?
<adrien> ~what do you mean?
<bernardofpc> I had to issue "canvas#event#add [ `BUTTON_PRESS ];" so that these events would be gotten by the Gtk loop
<bernardofpc> I tried naïvely to add `MOTION_NOTIFY to the list and it did not work
<adrien> :)
<bernardofpc> I removed the `MOTION_NOTIFY, it seems as the event is not getting through
<adrien> yeah, you need to enable each one
<bernardofpc> I tried that as well, and then it is where it shouted this error
<adrien> what do you write exactly?
<adrien> check the types
<adrien> it's `POINTER_MOTION
<adrien> so
<adrien> [ `BUTTON_PRESS | `POINTER_MOTION ]
<adrien> you should check the docs on gtk.org or gnome.org to get the details
<bernardofpc> http://lablgtk.forge.ocamlcore.org/refdoc/GdkEvent.html -> I used the "timed" type there, maybe that was the problem
<bernardofpc> (where I say the `MOTION_MOTIFY)
<bernardofpc> amazing, thanks a LOT
wilberine has joined #ocaml
<bernardofpc> time to lunch !
<adrien> lablgtk docs shows the types but for the explanations it's on gtk.org or gnome.org
<adrien> if you need to understand how something is used and it's not obvious through only the types, just go to {gtk,gnome}.ogr
<adrien> org*
sorethroat has joined #ocaml
shinnya has quit [Ping timeout: 260 seconds]
sorethroat has quit [Ping timeout: 260 seconds]
wilberine is now known as diginux
pminten has quit [Quit: Leaving]
Amanite has joined #ocaml
<Amanite> hi
<Amanite> can someone tell me how can I fix my code?
<Amanite> thanks a lot
<Drup> the function application f(x) is not a priority
<Drup> g f(x) is parsed the same as g f x
<Drup> if you want to apply f to g, you need to do g (f x)
<Drup> f to x*
<Amanite> ah
<Amanite> so I just need an extra set of parenthesis for my log?
lostcuaz has joined #ocaml
<Drup> for both float_of_int
<Drup> also, note that to print !i, you could just use %i, insted of converting to float
<Amanite> oh well
<Amanite> right
<Amanite> correcting it
sorethroat has joined #ocaml
<Amanite> ok it's working !
<Amanite> thanks
sorethroat has quit [Ping timeout: 260 seconds]
<kamatara> that's the problem with french people, they code in French
<Amanite> Depends
<Amanite> when I expect my code to be read by a lot of people, I use english variable names and comments
<kamatara> that's not a question, every code must be in english (american english)
<kamatara> that's not relative
<Amanite> if I wanted to share my code with my french classmates, why would I put another language barrier
<kamatara> Amanite, french is a barrier
<Amanite> english is a barrier for some people
<kamatara> even if you discuss with french you code in english
<kamatara> english for computer science it's easy, there is no excuse
<kamatara> especially today when we have dictionaries
<Amanite> dude I'm fluent in english
<Amanite> It's just that I don't want to get a phone call every 5 minutes asking me to explain what did I mean in my comments
<kamatara> if they can't understand english, they can't read documentation, so they can't be developers
<kamatara> sso it's not a problem
<kamatara> why do you think american made fun of ocaml? because it's full of french logic and nobody want that in the world
<Amanite> americans make fun of ocaml?
<Drup> thanks for you input kamatara, you can now hide yourself in order not to became even more ridiculous thatn you are now
<Amanite> I thought they were barely aware of its existence
<kamatara> Amanite, yes, they always moke the french syntax
<kamatara> but maybe you're too concerned about your little french way of coding
<Kakadu> kamatara: what is Frech logic?
<kamatara> I'm sure your OS is in French
<Amanite> Give me an example of french syntax
<Amanite> Haha, no
<Amanite> I'm running GNU/Linux Debian in english
<kamatara> Kakadu, source file are in iso-8859-1 and not in ASCII
<kamatara> Amanite, good
<kamatara> Kakadu, thta's a shame
<Amanite> my other desktop computer runs Windows in english
<Amanite> because all troubleshooting documentation is in english
<Kakadu> kamatara: That's just legacy code
<Amanite> kamatara: what do you mean by french syntax
<kamatara> Kakadu, that's not legacy, that a major flaw in design
<kamatara> something which is not thought for ASCII,
<kamatara> I know only one language which is not in ascii or unicode, and which one? ocaml
<Drup> since when ? the compile accept ascii and unicode file just fine
<kamatara> that's a fucking joke, i code since 20 years, and i never see that elsewhere else
<adrien> kamatara: can you stop criticizing what everyone does and how they do it? especially people new to the channel?
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<kamatara> adrien, you want to treach me about french in code ?
<Drup> especially if you're saying bullshit
<Amanite> nah it's fine, I'm just wondering what does he mean by french syntax
<kamatara> Amanite, go to haskell forum and ask, they will teach you why ocaml is a joke
<Amanite> oh boy here we go
<kamatara> because of the fucking french community
<Drup> funny
<adrien> kamatara: I didn't say anything around that; I'm only trying to point out that it's not a very nice way to welcome new people
<Amanite> did anyone get anything done in Haskell besides xmonad?
<adrien> there's a way to do constructive critiscim
<adrien> criticism
<Amanite> OCaml is used in airplanes and automated stock trading
* adrien spanks his fingers
<Amanite> Haskell is used in... ?
<kamatara> adrien, that's always where we must begin, if it's french, you spank and you say try again. You help only when it's written in english
<Drup> ( Amanite : for the record, haskell also have industrial applications)
<adrien> no
<Drup> ( Amanite almost as much as ocaml )
<kamatara> if someone show me french code, I refuse to help him until it's rewritten in english
<Amanite> Drup: really?
<Drup> ( Amanite : but that's not the point here)
<adrien> Amanite: even cobol has industrial applications :D
<adrien> COBOL*, sorry
<kamatara> haskell is far more used than ocaml in the world
<Drup> be careful, kamatara is capable to argue that COBOL is a good language because it's stable, it takes ASCII input and portable
<kamatara> you're full of illusion if you think that caml compete with tit
<Drup> kamatara: no it's not
<kamatara> Drup, lies, lies, lies
<adrien> kamatara: also, if you have issues with ocaml or its community, think ocaml is a joke or have serious disagreements with the people involved in OCaml, you're free to go elsewhere
<kamatara> leave you'r french world and discover the worlds
<Amanite> you're french world?
<kamatara> haskell rulez, ocaml is nothing
<adrien> your*
<adrien> kamatara: again, if you dislike it, you're free to leave
<Drup> kamatara: I do, I'm working with haskell people on haskell code, in a haskell-only environment
contempt has quit [Ping timeout: 265 seconds]
<kamatara> I like caml, but i spit on the french community which read french documentation and write french code
<Amanite> great mindset
<Drup> kamatara: and I assure you, haskell is not more used than ocaml
<Drup> kamatara: the haskell community is more vocal
<Drup> that's a fact
<Drup> but in practice, it's more used, there is currently a shitload of buzz surrounding haskell. It doesn't mean a lot of people are actually doing stuff in haskell
contempt has joined #ocaml
<Drup> it's not more used*
<Anarchos> kamatara you don't need to be so rude :)
<Drup> and if you think only french people are working on ocaml, some people here are going to be a bit pissed of that you consider they are doing nothing
Thooms has quit [Quit: WeeChat 0.3.8]
<Drup> no, if you stay in you butt-hurt line "I'm right and you are all a bunch of french shit", they I advice you to get out before you are forced to. There is no point to let toxic people talking in this channel, and you clearly are toxic.
<Drup> now*
<kamatara> Drup, you're deforming my speech, you lost the debate
<Drup> sure.
<Amanite> congrats, you won, have an internet medal
<Drup> <3
<kamatara> sage
<Amanite> sage?
<Amanite> do you think this is 4chan?
<Eyyub> :d
<kamatara> even in front of truth you deny, that's pathetic
<Amanite> Yeah there are more results on Google with Haskell than with OCaml
<Amanite> And what is this supposed to prove, exactly?
<Amanite> You could have used googletrends instead of this silly website to convey your point btw
<Amanite> looks like OCaml is popular in south korea
<kamatara> ha yes and South Korea is the world, damn I feel stupid now
<Amanite> no, I was just surprised
<bernardofpc> let met just start a point here
<bernardofpc> where were you born kamatara ?
<Drup> bernardofpc: guess were :D
<kamatara> bernardofpc, in France, and since I'm a child I read doc in English
<Amanite> well his english is far from perfect
<kamatara> and write code in English
<Amanite> so probably not in the us
<Amanite> hah
<Kakadu> haha
smiler has quit [Ping timeout: 264 seconds]
kamatara was kicked from #ocaml by adrien [let me tell you a truth that trascends programming languages: you _are_ annoying]
<bernardofpc> did you learn "one plus one equals two" or rather "un plus un égale deux" ?
<adrien> sorry bernardofpc :P
<bernardofpc> no pb
<adrien> now I can go out and eat pastries
<bernardofpc> In fact, one of the things I realized was that I learnt better in portuguese than in english
<bernardofpc> and having books in portuguese was, therefore, a major thing into "getting" real analysis or other advanced math
<bernardofpc> no matter how long I've known english, still a portuguese explanation beats everything
<bernardofpc> and that's curious, but I guess that explains why russian math, american math and french math are very much different
<bernardofpc> I can only second-guess that this also happens in programming
<Amanite> can confirm, french math is really obfuscated
<bernardofpc> (and I am learning german precisely to get the mindset of Euler, Gauss and Riemann)
<bernardofpc> Amanite: it's a different stance towards how tihngs are done and said
<bernardofpc> even if the "same theorems are true", everything else is different
<adrien> bernardofpc: well, same here: many english-speaking people have been believing I was actually american or british but even with that, I still understand maths/physics/... more easily in french
<Amanite> I was joking
<Drup> Amanite: you don't like Bourbaki's style ? :)
<Anarchos> Drup bourbaki style is pretty concise
<Drup> concise
<Drup> yeaaah :D
<Anarchos> i don't see problem there, as soon as you don't pretend it is a lesson to read for undergraduate
<bernardofpc> as long as you treat it as Coq input, it's fine
<bernardofpc> Coq can take your theorems and arrange them in proper order and you realize the new teorem really follows from those spelled
<Drup> bernardofpc: more like a point-free style haskell one liner, actually
<bernardofpc> (my mind always comes to "by prop 2.5.13 and lemmas 4.3.2 and 4.3.3, this proves theorem 4.3.1"
<Drup> it's right, it's beautiful, and absolutely not helpful :D
<bernardofpc> well, gotta go as well
<bernardofpc> bonne soirée les gens :D
<bernardofpc> (and good afternoow everybody, even if "everybody" is not a perfect translation)
<Amanite> ++
philtor has joined #ocaml
<zzaz> bernardofpc: btw, thanks for the help!
zzaz has quit [Quit: leaving]
ygrek has quit [Ping timeout: 252 seconds]
pango has joined #ocaml
ontologiae has joined #ocaml
sorethroat has joined #ocaml
Amanite has quit [Quit: Lost terminal]
mort___ has joined #ocaml
Anarchos has quit [Ping timeout: 272 seconds]
Anarchos has joined #ocaml
watermind has quit [Read error: Connection reset by peer]
watermind has joined #ocaml
sheijk has joined #ocaml
sagotch has joined #ocaml
FreeArtMan has quit [Quit: main.lv]
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
Arsenik has quit [Remote host closed the connection]
zpe has quit [Ping timeout: 260 seconds]
Arsenik has joined #ocaml
mcclurmc has joined #ocaml
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
NoNNaN has quit [Remote host closed the connection]
smiler has joined #ocaml
mort___ has quit [Quit: Leaving.]
mort___ has joined #ocaml
<Drup> rgrinberg: in your json benchmark, would it be possible to add raw unsafe marshal and Bencode for reference ?
<Drup> they're not json, but that's still marshalling :)
<companion_cube> :D
<gasche> I don't think that would make sense
<Drup> why ?
<gasche> the difference between both Json's library is likely to be a few silly constant factors
<gasche> the nice thing about a benchmark is that authors of one library can look at why they perform poorly, and fix their code by comparing to the other
<companion_cube> the API can also be a source of additional speed
<companion_cube> (or additional slowness)
<gasche> that wouldn't work if you benchmarked a json library against a Bencode library
<companion_cube> gasche: what do you think about ocaml-ty, btw?
<Drup> we are talking about serializing, it's interesting to look at all the options. You are talking from the library designer point of view, I'm talking from a user point of view
<companion_cube> especially when comparing text-based encodings, indeeed
<gasche> Drup: if the user thinks that using JSON comes at no performance price, he or she is a fool
<Drup> gasche: then put e measurement on the performance price
<gasche> but I would agree that quantificative informations about that price is always good to have
Thooms has joined #ocaml
<companion_cube> especially if you have big string values, json can add a cost for escaping those strings
<Drup> if the cost is *2 or *100, the balance is not the same
<companion_cube> (say, if you put json in json strings)
<gasche> well
<Drup> gasche: and the marshal module was more for baseline, The most interesting comparison is with Bencode, which is the same kind of format
<Drup> (assuming marshal is indeed faster, still not sure about that)
<companion_cube> it probably is
<companion_cube> but it's less safe and flexible in general
<companion_cube> (tradeoffs)
<Drup> Well, I had surprised about the speed of stdlib's stuff before
<Drup> (hello Stream)
<companion_cube> marshall is a primitive written in C, I believe
yacks has quit [Quit: Leaving]
cdidd has quit [Read error: Connection reset by peer]
ggole has quit []
nickmeharry has joined #ocaml
speckle has joined #ocaml
<speckle> hey, anyone used mlkit?
<companion_cube> is it a binding to webkit?
sorethroat has quit [Ping timeout: 272 seconds]
<speckle> no, it's an implementation of ML with region-based memory management, as far as I know. I'm not sure where else to ask, since there's not really an #ml channel
<speckle> it looked interesting, but it didn't look like a whole lot of people were using it
<companion_cube> never used it, but it sounds interesting
<companion_cube> no dialect of ML is widely used anyway ;)
<speckle> hehe
tobiasBora has joined #ocaml
<tobiasBora> Hello !
<companion_cube> hi
ontologiae has quit [Ping timeout: 245 seconds]
<tobiasBora> There is a strange thing in Ocaml (and several others languages) : when I do a for loop "for k = 0 to n", the n is included in the loop. Or in computer science we count from 0 so the n is never included, and that's why there is lot's of -1 in our loops
<Anarchos> tobiasBora and what is strnage ? just a different convention !
<Anarchos> tobiasBora as far as i recall it was the same in pascal
<tobiasBora> Is there a way to do a for loop like in python "for i in range(n)", ie i ∈ [0,n[ or do I need to use i ∈ [1,n] ?
<Drup> for i = 0 to n - 1 :D
<Anarchos> Drup you were faster than me !
<Drup> don't be afraid of -1, they do bite sometimes, but it's not their fault x)
mreca has joined #ocaml
<Anarchos> Drup i wonder if i can write a complex loop : for a = 0 to 1+i do ...done ;)
<tobiasBora> Anarchos: The problem is that there is in fact two conventions in the same time : usually the intervals we use in arrays for example are like this : [a,b[ (Ex : [0,n[), but in the for loop the convention is [a,b] and I think that it's quite strange to keep two differents conventions. I saw a great article where the scientists gave better explanations than me but I can't find it...
<Drup> tobiasBora: are they ? never seen anyone counting "to n" without including n
<companion_cube> it's very common to write for i = 0 to Array.length foo - 1 do .... done
<companion_cube> or just Array.iteri ;)
<Drup> "to n" means including for me, but, well vOv
osa1 has joined #ocaml
<tobiasBora> companion_cube: The -1 here is a dirty (but common) "hack" to hide a more deep problem I think
<companion_cube> nah, that's not a problem
<companion_cube> you don't always do for loops to iterate on arrays
<companion_cube> sometimes it's just to iterate on integers, and in this case, including the higher bound is ok
<companion_cube> also, for i = n downto 0 do ... done ← sounds more logical to include the 0
<companion_cube> at least to me
osa1 has left #ocaml []
<Drup> (actually, you shouldn't iterate or arrays with a for loop, an iterator (aka, Array.iteri) is better)
<nickmeharry> Hy guys, working on my first actual project with OCaml, and I feel like I'm missing something obvious here:
<tobiasBora> One argument in the article I can't find is that the [a,b[ intervals have one avantages : to have the number of objects in it just to b-a. With [a,b] it's b-a+1 and that's why we should always use [a,b[. An other argument was that It's not possible to do an empty interval with only positive numbers with [a,b] because [0,0] include the 0 while [0,0[ don't...
<Anarchos> tobiasBora the people who program loops should know their maths. period.
<tobiasBora> So the proper way to count is with this kind of intervalls, and that's why I think it's strange to don't respect this convention in the for loop
<companion_cube> nickmeharry: parenthesis in types
<companion_cube> (int * MyMod.a) list
<Drup> tobiasBora: no offense, but that's a lot of nitpicking for very little
<nickmeharry> Ok, I'll try that.
<nickmeharry> Yup, that did it. Thank you, companion_cube
<companion_cube> nickmeharry: do you understand the error? :)
<tobiasBora> companion_cube: maths period ? And in python when you do "for i in range(n)", you do n times the loop even if you don't include n.
<nickmeharry> Yeah. I just thought the * in the type signature bound tighter than it does, appearently.
<companion_cube> nickmeharry: exactly
<companion_cube> tobiasBora: that's just a different convention
<tobiasBora> Drup: Yes I know, but that's the kind of details which annoye me... I know it's stupid ^^
<companion_cube> when I write for i=0 to n do ... done it sounds like n is included ^^
<tobiasBora> companion_cube: Yes but in python the n isn't included.
<companion_cube> I don't see how that makes python right and ocaml wrong :)
dant3 has quit [Remote host closed the connection]
<companion_cube> range() is a bit like a consummable array
<tobiasBora> companion_cube: and I find it's strange to use two conventions... We should begin our array from 1 with this convention :-)
<companion_cube> whereas ocaml provides a for loop
<companion_cube> tobiasBora: for loops aren't tied to arrays
dant3 has joined #ocaml
sorethroat has joined #ocaml
<tobiasBora> companion_cube: No but they are tied to intervals, like array, so the same interval convention should be used everywhere.
<tobiasBora> But if for example I wan't to define my own loop "syntax" (I mean if I don't wan't to include n), how could I do that ?
<tobiasBora> I can define it in Ocaml, in a C program, or I must compiled my own ocaml version ?
<companion_cube> you can't extend the syntax (disregarding camlp4) but you can write a higher order function
<companion_cube> val myforloop : int -> int -> (int -> unit) -> unit
<companion_cube> and there you can exclude the higher bound if you wish
<Drup> tobiasBora: If you want to be very adventurous
<Drup> you can use the current version of pre-extension-point syntax modifiers
<companion_cube> I think that's *really* overkill
<Drup> and rewrite for loops with a -1 at the ned
<Drup> oh, overkill ? no
<companion_cube> loops in OCaml aren't that useful anywya
<Drup> it's super simple to implement
<Drup> excessively confusing for other people ?
<Drup> hell, yes :D
<Drup> (but it's actually very simple to implement, and you will even have the same syntax as for loops !)
<companion_cube> ahem
<companion_cube> don't encourage him (her) :)
sagotch has quit [Remote host closed the connection]
<tobiasBora> Oh nice :-)
cdidd has joined #ocaml
<speckle> There's a very good reason for abstracting away the for loop
<tobiasBora> companion_cube: with your method (like to Array.itari method) I have a question about benchmark :
<speckle> If we ever have a parallel implementation of the underlying language, and our operation is "do operation X using each object in set Y", we may want that to be optimized
<Drup> tobiasBora: I await with great impatience when you will come and say "I keep having errors because I'm not used to this convention with array loops, it was a bad idea" :D
<companion_cube> speckle: it's more that you have a higher abstraction ^^
<Drup> tobiasBora: Array.iteri should be faster
<companion_cube> really??
<tobiasBora> When you send a function to an other function, it's inlined, so it's quite long to send no ?
<companion_cube> hmmm no, inlining is optional
<Drup> companion_cube: inlining + unsafe_get/unsafe_set
<tobiasBora> Drup: I may do it but I'm curious ^^
<companion_cube> Drup: ah
<companion_cube> I agree for unsafe_get
<Drup> it *is* a for loop after inlining
<Drup> except that unsafe_set/get, since we are sure inside this function that we are inside the bounds
<companion_cube> Drup: only if the function is inlined
<Drup> if we add a very optimizing compiler, we could also have crazy // stuff, but that's not the point here :p
<companion_cube> which is not always the case
<speckle> you're right, companion_cube, having a higher abstraction is good for many other reasons. Like easier refactoring, better readability, and so forth
<speckle> As long as the abstraction itself is clear, everything built on top of it can sometimes be vastly simplified
<tobiasBora> I'm maybe not using inline with the good sense... I will give you the example of my last program : I had a recursive function which uses functions in arguments, and when I decided to remove the function from the arguments it was 100 times faster because (as I understood) the whole function is written in the argument each time you call it. So I'm afraid that the Array.iteri loop has the same problem.
<Drup> companion_cube: if the function is simple, I think you have a good chance for it to happen. (especially once we have pierre's change)
rython has joined #ocaml
zpe has joined #ocaml
<companion_cube> tobiasBora: it's not "written in the argument"
<companion_cube> there is a proper notion of function call
<flux> tobiasbora, 100-fold performance difference sounds extremely wild
<flux> tobiasbora, I think there was something else that was causing the trouble :-o
<flux> basically a function argument is a pointer to the function and environment, right?
<Drup> agree, with manual inlining, I once had *2 or top *3 performance gain, but not *100 O_o
<tobiasBora> companion_cube: Could you explain me this notion ?
<companion_cube> tobiasBora: when you call f 1 "foo" (for instance)
<companion_cube> it reserves some space on the stack, puts 1 and "foo" in the new space, and jumps into the code for f
<companion_cube> there is no "duplication" of code involved
<tobiasBora> Well... With the first version I need about 45mn to compute until the size 13, and with the new one it's in less than 1 sec.
<Drup> you probably changed the complexity :D
<Drup> a simple inlining is never gonna give you that
<companion_cube> indeed
<tobiasBora> I can't change the complexity like this because the complexity is already optimum and I didn't change the algorithm ^^
<Drup> on paper, sure
<Drup> in practice ... :3
<Drup> well, we would need to see the whole code before and after, to be sure
<tobiasBora> companion_cube: you mean something like a pointer ?
<flux> well, if it happens so that the memory requirements or the size of the working set accidentally increased, it could have effects via cache being overflown
<flux> but even that would probably give only performance difference of 10x..
<Drup> and anyway tobiasBora, iteri is not a recursive function
<companion_cube> tobiasBora: a pointer to the code of f
<companion_cube> the code of f uses the top stack frame to find its parameters
<tobiasBora> companion_cube: really ? So when you call it recursively it's like send a pointer ?
<tobiasBora> Drup: It's coded with a for loop ?
<companion_cube> no, it's also allocating some space on the stack
<companion_cube> *unless* the call to the function is in tail position
<Drup> tobiasBora: of course
FreeArtMan has joined #ocaml
<tobiasBora> companion_cube: I can't understand, what is putted in the stack space ? Only the pointer or something else ?
<companion_cube> on the stack frame (reserved to the function call) you put parameters (arguments of the function)
dant3_ has joined #ocaml
rython has left #ocaml []
<tobiasBora> and when the argument is a function it's only a pointer which is recorded ?
<companion_cube> yes
<companion_cube> (well it's more complicated when the argument is a closure, but basically that's it)
<companion_cube> function call is pretty cheap :)
dant3 has quit [Ping timeout: 248 seconds]
<bernardofpc> exception Bottom of int;; -> so much for "no ;; in .ml"
<tobiasBora> Oh yes, how does it work for closures ? Is it cheaper or not ?
<companion_cube> closures are objects allocated on the heap
<bernardofpc> closures are more expensive than "normal" function calls
<tobiasBora> Drup: Indeed... And what does the unsafe_get ?
<bernardofpc> but not much
<companion_cube> they contain the pointer to the actual code, and parameters closed upon
<Drup> tobiasBora: same as get, but don't check boundaries
<Drup> (get = .(x))
<Drup> tobiasBora: (corollary : if you screw up, you get a segfault instead of an ocaml exception =)
<companion_cube> heh
<tobiasBora> How ok I see
<Drup> the performance gain is small, but noticable on big arrays with very cheap operation by element
<Drup> there is a compiler flag that also transform all call to get to unsafe get
<Drup> perfect for dirty pranks betweem ocamlers =°
<tobiasBora> Really ? What is this flag ?
<Drup> -unsafe =')
<companion_cube> :D
<companion_cube> nice
<tobiasBora> companion_cube: Ok thank you. So a closure is considered as an external function with others parameters which are the variables used in the function ?
<tobiasBora> Drup: Oh nice, I'll give it a try ^^
Arsenik has quit [Remote host closed the connection]
<Drup> you shouldn't ^^
<companion_cube> tobiasBora: let f x y = x+(y*2);;
<companion_cube> let g = f 1;;
<companion_cube> g is a closure
<companion_cube> because it "captures" the x
<companion_cube> so, g is actually a memory block containing a pointer to the code of f, plus the value of x (1 here)
<Drup> except for very specific contexts, the performance gain is not worth it, considering the huge unsafety factor. And in those contextes, you should use either a stdlib function like iteri, or in the worst case, use the unsafe function manually.
<tobiasBora> Oh so I didn't understand what is a closure. I though it was something like
<tobiasBora> let f a =
<tobiasBora> let g b =
<tobiasBora> b + 1
<tobiasBora> in
<tobiasBora> g a
<tobiasBora> ;;
<companion_cube> so here it's not a closure
<companion_cube> see, the code of g doesn't depend on anything "outside" of g
mw1001 has joined #ocaml
<tobiasBora> When I do something like this, is it "expensive" to create g ? (every time it's created a new time or not ?)
mw2002 has joined #ocaml
<companion_cube> let f a = let g b = b+a in g
<companion_cube> ↑ here g is a closure
<companion_cube> because it captures the "a"
mw2002 has quit [Client Quit]
<companion_cube> in your case, no, because it's not a closure
<companion_cube> in my case, every case you call f you create a new closure and return it
<tobiasBora> Yes my example was bad
<companion_cube> see the difference?
<Drup> (actually, in this case, the compiler is probably transforming this into a two argument functions ... I hope
<tobiasBora> Oh really ? So it's really ugly to call f in g, and it's better to make g outside ?
<companion_cube> no idea :D
mw1001 has quit [Client Quit]
<companion_cube> tobiasBora: what do you mean?
<Drup> tobiasBora: no, it's perfectly fine to put g inside f, that's note this issue
<Drup> not*
<companion_cube> let f a b = b+a;; ← same thing, indeed
<tobiasBora> companion_cube: I mean sometimes I need to create a function g which will call f which will call g... And when I need that I don't know if it's better to create g with f in parameters or to put g inside f (and don't take f in parameter)
<companion_cube> tobiasBora: let rec f = ... and g = ...
<tobiasBora> Drup: Why ? if everytime g is created again it's not very efficient not ?
<Drup> tobiasBora: it's not "created" again, and it would be the same if g was outside
<Drup> "let x = 3 in let g y = x + y in .." is the same
<Drup> g depend one something outside
Sim_n has joined #ocaml
Simn has quit [Ping timeout: 252 seconds]
lostcuaz has joined #ocaml
mort___ has quit [Quit: Leaving.]
<tobiasBora> So if I understand well these two functions are equivalents : http://paste.ubuntu.com/6905554
<tobiasBora> uhm
<tobiasBora> Not this version is better
<companion_cube> looks pretty similar
tane has quit [Quit: Verlassend]
<tobiasBora> Drup: And do you have some doc about pre-extension-point syntax modifiers ?
<tobiasBora> companion_cube: Ok thank you !
<Drup> there is an error in the first add
<Drup> it's add f r
<tobiasBora> Yes indeed
<Drup> and no, it's not equivalent
<Drup> a closure in the second case, no closure in the first one
<companion_cube> how so?
<companion_cube> oh, it should be add2 in the recursive case
<Drup> I suppose so, yes
<companion_cube> but assuming this, the inner function is closed and doesn't trigger an allocation
<companion_cube> afaict the compiler moves it outside
<Drup> oh yeah, the compiler is probably clever enought to transform the second into the first
<Drup> but the first is better
demonimin has quit [Ping timeout: 246 seconds]
<companion_cube> it may be more readable, if that's what you mean
<tobiasBora> Maybe Drup means that when it's necessary to make suppositions of the intelligence of the compiler it's more proper to do it by ourself.
<Drup> huum, not really
<Drup> but in this case
<Drup> actually, it depends
<tobiasBora> Wooow... I tried to use unsafe and my code is 10% faster !
ulfdoz has quit [Ping timeout: 248 seconds]
<Drup> I don't advice to make manual optimisation yourself (as opposed to letting the compiler do them) when 1) you are not sure it's worth it 2) it impede readability and usability
<Drup> but in this case
<Drup> the fast code is both more reusable and cleaner
<Drup> so ...
<tobiasBora> I understand ^^
<companion_cube> Array.iteri is good
<tobiasBora> And do you have some doc about pre-extension-point syntax modifiers ? I'm curious and a fast research didn't help me
<companion_cube> there is camlp4
<companion_cube> but please don't use it for something as basic as a loop ::
<companion_cube> :/
<tobiasBora> Even for training ? ^^
<Drup> hum, there is no doc really
<Drup> but there are some examples
<tobiasBora> Where could I find them ?
<Drup> wait, I'm searching
<tobiasBora> Thank you
<tobiasBora> And I found the article I talked about : http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF
<tobiasBora> (it wasn't exactly him but it's the nearer)
<Drup> http://www.danmey.org/omonad.html look at the source of this
<Drup> and explore the related stuff in compiler libs
<Drup> basically, the ppx is going to receive the AST from the parser and transform it a little bit (+1 somewhere :p)
<Drup> (btw, did I said enough it was a terrible idea ? :D)
<tobiasBora> Thank you !!!
<companion_cube> terrible idea!
<companion_cube> (again)
<tobiasBora> What is AST ?
<Drup> Abstract Syntax Tree
<tobiasBora> You may are right, but when an idea is in my head I can't get it out...
<tobiasBora> I see.
Kakadu has quit [Quit: Konversation terminated!]
<adrien> working with ppx is much easier than working with camlp4
<adrien> but that doesn't make it simple either :P
<companion_cube> don't
<tobiasBora> So ppx is only a "script" called by the original Ocaml compiler just after the parser
<Drup> yes
<Drup> and it basically, the "script" only contains a function AST -> AST
<Drup> (that's "mapper" in omonad's source)
<companion_cube> stoooooooop
<Drup> you need to register your fonction also, with "Ast_mapper.main my_fun"
<tobiasBora> In the source example I see often that : <--, what is it ?
<adrien> if you're not enough pragmatic according to companion_cube, something is probably wrong with your approach :P
<Drup> that's the syntax added by omonad
<companion_cube> adrien: stop this diffamation!
<adrien> it's not diffamation if it's proven :P
<adrien> and I have proofs :P
<Drup> It's this sort of idea that are so terrible that it can only be wonderful :D
<companion_cube> I require those proofs, now!
<companion_cube> :D
<tobiasBora> XD
<bernardofpc> well, I have done a fair amount of LablGtk this Weekend
<bernardofpc> is there any place where I can look at simple examples to get a bit of coding styles ?
<bernardofpc> (I could also post 200+ lines of my main.ml :D)
<companion_cube> maybe, take a look at why3? it depends on lablgtk
<companion_cube> or coqide :>>>>>
<adrien> bernardofpc: the lablgtk sources :P
<companion_cube> (not)
<adrien> there are several small examples
<adrien> like quite a lot
pkrnj has joined #ocaml
<adrien> if only Drup was adding the support for the broadwell backend of GTK+ in js_of_ocaml...
<companion_cube> gtk in ocaml in javascript in the browser
<adrien> we could have an interactive gallery of examples on the website
<companion_cube> what could possibly go wrong?
<adrien> companion_cube: the browser being GTK+ of course
<adrien> (or Qt?)
<companion_cube> yes, and running in itself
<tobiasBora> Thank you everybody for your help, I learnt lot's of things again, and I prom... say to companion_cube that I will try no to do (so) stupid things with monad ;-)
<companion_cube> good luck :D
axiles has quit [Quit: Quitte]
<companion_cube> but please, don't worry too much about the inclusive bound of "for"
<Drup> no no, go on, I want to see the end result and the terrible thing that happen after :D
<companion_cube> you're an agent of doom
<tobiasBora> But I think this inclusive bound is soo ugly... When I saw for the first time the python syntax I though "Oh it's horrible !", and now I love it !
<Drup> companion_cube: and very proud of it :D
<adrien> typical stockholm syndrom
<companion_cube> tobiasBora: be adaptable ;)
ollehar has quit [Ping timeout: 246 seconds]
<tobiasBora> companion_cube: I try... But it's really painfull when I find it unproper ;-) Well, I'd like to close this discution with a beautifull sentence :
<tobiasBora> "Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration." -- Stan Kelly-Bootle
<tobiasBora> Thank you again everybody !
tobiasBora has quit [Quit: Konversation terminated!]
<Drup> there is an article from dijksrta on the subject :D
sorethroat has quit [Ping timeout: 250 seconds]
<companion_cube> on arrays, yes, not loops ;)
<adrien> and it's for 0 or 1, not the end :P
<companion_cube> it's related -_-
<adrien> tobiasBora also wanted to start at 1? :o
<companion_cube> no
<adrien> so not that related :P
<companion_cube> you're talking arrays here, not loops
<adrien> I'm actually mostly talking crap :D
<companion_cube> so surprising !
Yoric has joined #ocaml
<adrien> you're hurting my feelings
sheijk has quit [Quit: .]
mreca has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shinnya has joined #ocaml
Sim_n is now known as Simn
mort___ has joined #ocaml
pkrnj has quit [Quit: Computer has gone to sleep.]
<bernardofpc> Knuth also has something on 0 vs 1
<bernardofpc> (and [a,b[ vs ]a,b] vs [a,b] etc)
<companion_cube> I guess he agrees that [a,b[ is better?
<Drup> (I find Dijkstra funnier to read than Knuth, though :p)
<bernardofpc> "Half-open intervals that include the left endpoint but not the right are slightly more common than those that include the right endpoint but not the left; and floors are slightly more common than ceilings. So by Murphy's Law, the correct rule is the opposite of what we'd expect: [a,b[ has (ceil(b) - ceil(a)) elements and ]a,b] has (floor(b) - floor(a)) elements"
<bernardofpc> Drup: I never found Dijkstra funny :/
<bernardofpc> he's too sarcastic for my tastes, perhaps
<bernardofpc> (the quotation is from Concrete Math, by Graham+k+Patashnik)
<Drup> this while floor vs ceil argument is irrelevant if you use integer to design ranges :p
<Drup> -while*
<companion_cube> :)
Myk267 has joined #ocaml
FreeArtMan has quit [Quit: main.lv]
dant3_ has quit [Remote host closed the connection]
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
Yoric has quit [Ping timeout: 265 seconds]
Anarchos has quit [Quit: Vision[0.9.7-H-20131020]: i've been blurred!]
pkrnj has joined #ocaml
wolfnn has quit [Quit: Leaving.]
S11001001 has joined #ocaml
S11001001 has quit [Changing host]
S11001001 has joined #ocaml
dant3 has joined #ocaml
dant3 has quit [Read error: No route to host]
dant3 has joined #ocaml
so has quit [Ping timeout: 250 seconds]
dant3 has quit [Read error: No route to host]
dant3 has joined #ocaml
dant3 has quit [Read error: No route to host]
diginux has quit [Ping timeout: 265 seconds]
ollehar has joined #ocaml
tristan_1 has quit [Remote host closed the connection]
tristan__ has joined #ocaml
diginux has joined #ocaml
ollehar has quit [Ping timeout: 246 seconds]
so has joined #ocaml
tristan__ has quit [Remote host closed the connection]
tristan__ has joined #ocaml
Thooms has quit [Ping timeout: 272 seconds]
diginux has quit [Remote host closed the connection]
tristan__ has quit [Remote host closed the connection]
diginux has joined #ocaml
tristan__ has joined #ocaml
so has quit [Ping timeout: 250 seconds]
so has joined #ocaml
pkrnj has quit [Quit: Computer has gone to sleep.]
S11001001 has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
pkrnj has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
watermind has quit [Read error: Connection reset by peer]
watermind has joined #ocaml
watermind has quit [Client Quit]
watermind has joined #ocaml
ygrek has joined #ocaml
darkf has joined #ocaml
dant3 has joined #ocaml
Simn has quit [Quit: Leaving]
mort___ has quit [Quit: Leaving.]
dant3 has quit [Ping timeout: 250 seconds]
madroach has quit [Ping timeout: 252 seconds]
madroach has joined #ocaml
shinnya has quit [Ping timeout: 250 seconds]
covi has joined #ocaml
<covi> What is 'struct' in the context of modules/
<Drup> "begin" :)
S11001001 has joined #ocaml
S11001001 has quit [Changing host]
S11001001 has joined #ocaml
ontologiae has joined #ocaml