Banana changed the topic of #ocaml to: OCaml 3.08.1 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
<palomer> what do you guys think about implicit constructors?
<palomer> like we could have datatype a = int | float; and then foo(3) = 2 | foo(3.4) = 4
<Demitar> async_, a couple of ways to do it are listed in the manual (bottom of the ocamlc section iirc). And yes, it's evil. :)
<Demitar> palomer, err? What are you talking about?
<Demitar> Some kind of overloading constructor inference thingie?
<async_> ok, time to concat the files :)
<async_> hehe
<mrvn> palomer: How would you match against the type of a?
kinners has joined #ocaml
<palomer> mrvn, good point
shammah has joined #ocaml
CosmicRay has joined #ocaml
<mrvn> It would be nice if ocaml would optimize out the variant type for simple variants.
<Demitar> mrvn, how simple?
<mrvn> 'type foo = Foo of bla' as simplest case.
<Demitar> What would be the point?
<mrvn> 'type foo = X of x | Y of y' when x and y are distinc types already, like int and object.
<Smerdyakov> mrvn, how would you "optimize" that second case?
<Smerdyakov> mrvn, do you mean to use the tag bit?
<mrvn> yes.
<Smerdyakov> Clearly that doesn't work just because x and y are "distinct types."
<mrvn> There only are a very few distinct types. Most things end up as objects.
kinners has quit [Read error: 110 (Connection timed out)]
<Smerdyakov> You are using a different meaning of "distinct types" than I think most people would.
<mrvn> distinct in memory. Looking at the tag bit would be the obvious choice.
<Demitar> mrvn, just wanting to make sure. Are you actually having performance problems because of this? Or is it just a "nice to have" feature? :)
<mrvn> nice to have.
<mrvn> My cpu is too fast to have performance problems :)
<Smerdyakov> Try SML if you want that sort of thing.
<Smerdyakov> In MLton, there are no tag bits, so the second kind of optimization doesn't make sense.
<Smerdyakov> But the first one is certainly implemented.
<Demitar> Smerdyakov, what have we said about advocating other languages in here? ;-)
<mrvn> I think there are only two common cases where the optimization could be used: type foo = Foo of ... and type foo = Empty | of Foo of ...; cases-
<Smerdyakov> mrvn, MLton hits both of those.
<mrvn> unfortunately the later is usualy a type 'a foo
* Demitar usually relies on Smerdyakov to explain icky things to people wondering anyway. :)
<mrvn> Smerdyakov: how does it catch "None" vs "Some None"?
<Smerdyakov> mrvn, not sure, but it uses different representations for different instantiations of polymorphic types.
<mrvn> So it might be using the tag bit for None and Some.
<Smerdyakov> There is no tag bit with MLton.
<mrvn> How does the GC work then?
<Smerdyakov> Fancyness.
<mrvn> You need the tag bit to differentiate between int and pointer.
<Smerdyakov> Well, it might just be that values in registers are untagged.
<mrvn> Without it you can only do conservative GC and that can leak memory.
<Smerdyakov> It's quite easy to implement a completely tag-free runtime system, but it takes more work than people generally want to invest.
<mrvn> Smerdyakov: well, yes. registers should be untaged and unboxed.
<Smerdyakov> You just need to save shape information for use at GC-time.
<mrvn> Smerdyakov: the shape information then is your tag bit.
<mrvn> That would be like the array of float in ocaml I guess.
<Smerdyakov> No, shape information need not be stored in values themselves.
<mrvn> Obviously.
<Smerdyakov> It need not even be stored per-value.
<Smerdyakov> You only need per-program-point information.
<mrvn> One thing ocaml is realy bad at is unboxing within code that does not call the GC. Like the inner loop for the Mandelbrot Fractal.
<mrvn> defining that as extern C code gave a huge speedup.
<mrvn> Does ocamlopt do unrolling of tail recursions?
CosmicRay has quit ["Leaving"]
async__ has joined #ocaml
async_ has quit [Read error: 104 (Connection reset by peer)]
<Nutssh> It does tail recursion (has to!), dead code elimination, and, pretty much nothing else. No redundancy elimination, no unrolling.
<mrvn> It doesn't have to do tail recursion, it just wouldn't work very well.
<async__> does anyone know of a function that converts a float value into the 32 bit IEEE representation?
<mrvn> extern: float ieee_of_float(val f) { ... }
<mrvn> But why convert 64bit to 32?
<async__> float is 32 bits
<async__> mrvn: so you're saying i have to make a c function to do it?
<mrvn> async__: ocamls floats are doubles.
<mrvn> I don't think ocaml has a 32 bit float type.
async__ has left #ocaml []
<Nutssh> It doesn't, except that you can create arrays of 32bit IEEE floats with BigArray.
<mrvn> But afaik 32bit floats are slower on all modern cpus. So why bother?
vezenchio has joined #ocaml
kinners has joined #ocaml
mlh has quit [Client Quit]
mlh has joined #ocaml
Banana has quit [Read error: 110 (Connection timed out)]
det_ is now known as det
kinners has quit [Read error: 110 (Connection timed out)]
pharx has joined #ocaml
monochrom has quit ["hello"]
mrmr has joined #ocaml
<mrmr> so i was gonna take a look at ocaml and i was thinking my frist project might be a test engine for SMTP, IMAP and POP3, but I was reading a tutorial that said that Ocaml's UTF-8 support isn't that good. Is this till the case. I would really like support for many different charecter sets utf-7 and utf-8 being the most important
palomer has quit ["Leaving"]
<Nutssh> google is a friend.
pango has quit ["Client exiting"]
pango has joined #ocaml
mrmr has quit [tolkien.freenode.net irc.freenode.net]
pharx has quit [tolkien.freenode.net irc.freenode.net]
vezenchio has quit [tolkien.freenode.net irc.freenode.net]
calvin_ has quit [tolkien.freenode.net irc.freenode.net]
Nutssh has quit [tolkien.freenode.net irc.freenode.net]
themus has quit [tolkien.freenode.net irc.freenode.net]
mrmr has joined #ocaml
pharx has joined #ocaml
vezenchio has joined #ocaml
calvin_ has joined #ocaml
themus has joined #ocaml
Nutssh has joined #ocaml
pharx has quit [tolkien.freenode.net irc.freenode.net]
mrmr has quit [tolkien.freenode.net irc.freenode.net]
Nutssh has quit [tolkien.freenode.net irc.freenode.net]
calvin_ has quit [tolkien.freenode.net irc.freenode.net]
themus has quit [tolkien.freenode.net irc.freenode.net]
vezenchio has quit [tolkien.freenode.net irc.freenode.net]
mrmr has joined #ocaml
pharx has joined #ocaml
vezenchio has joined #ocaml
calvin_ has joined #ocaml
themus has joined #ocaml
Nutssh has joined #ocaml
mellum has quit [tolkien.freenode.net irc.freenode.net]
srv has quit [tolkien.freenode.net irc.freenode.net]
vincenz has quit [tolkien.freenode.net irc.freenode.net]
bacam has quit [tolkien.freenode.net irc.freenode.net]
drz has quit [tolkien.freenode.net irc.freenode.net]
Excedrin has quit [tolkien.freenode.net irc.freenode.net]
mflux has quit [tolkien.freenode.net irc.freenode.net]
Hadaka has quit [tolkien.freenode.net irc.freenode.net]
TheDracle has quit [tolkien.freenode.net irc.freenode.net]
Naked has joined #ocaml
Naked is now known as Hadaka
Excedrin has joined #ocaml
bacam has joined #ocaml
mellum has joined #ocaml
drz has joined #ocaml
pharx has quit [tolkien.freenode.net irc.freenode.net]
mrmr has quit [tolkien.freenode.net irc.freenode.net]
Nutssh has quit [tolkien.freenode.net irc.freenode.net]
calvin_ has quit [tolkien.freenode.net irc.freenode.net]
themus has quit [tolkien.freenode.net irc.freenode.net]
vezenchio has quit [tolkien.freenode.net irc.freenode.net]
calvin_ has joined #ocaml
mrmr has joined #ocaml
pharx has joined #ocaml
vezenchio has joined #ocaml
themus has joined #ocaml
Nutssh has joined #ocaml
Nutssh has quit [Excess Flood]
Nutssh has joined #ocaml
srv has joined #ocaml
vincenz has joined #ocaml
mrsolo has quit [Read error: 113 (No route to host)]
pharx has quit [tolkien.freenode.net irc.freenode.net]
mrmr has quit [tolkien.freenode.net irc.freenode.net]
themus has quit [tolkien.freenode.net irc.freenode.net]
vezenchio has quit [tolkien.freenode.net irc.freenode.net]
m3ga has joined #ocaml
m3ga has quit ["Client exiting"]
themus has joined #ocaml
tyler has joined #ocaml
<tyler> Are there any major differences between O'Caml 2.04, and 3.08?
<tyler> I'm reading the book linked from the homepahe
<tyler> but it apparently is targetted at that older release
<tyler> I mean, I'm sure there are lots of changes, but are there any that I, as a beginner, need to worry about?
<vincenz> the o'reilly book on the website should be for ocaml 3.07 or 3.08
<tyler> okay
<tyler> heh, just found I think
<tyler> using 3.08.1
<tyler> let a = -1.0 /. 0.0;;
<tyler> val a : float = neg infinity
<tyler> a + 1.0;;
<tyler> oh, doh
<tyler> just realised
<tyler> that's the one thing about o'caml I really, really don't likw
pharx has joined #ocaml
tyler has quit [Read error: 104 (Connection reset by peer)]
<vincenz> what?
srv_ has joined #ocaml
srv has quit [Read error: 104 (Connection reset by peer)]
mrvn_ has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
budjet has joined #ocaml
_fab has quit []
budjet has quit [Remote closed the connection]
avlondono has quit ["leaving"]
Submarine has joined #ocaml
shawn has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
Submarine has quit ["Leaving"]
solarwind has joined #ocaml
zigong__ has joined #ocaml
karryall has joined #ocaml
mlh has quit [Client Quit]
_fab has joined #ocaml
Godeke has joined #ocaml
malte has joined #ocaml
<malte> hi. is there a native way to slice lists? (sort of like [2:4] in python)
<vincenz> no because lists are implemented differently
<vincenz> lists in python are more like arrays
<vincenz> lists in ocaml are implemented in the cons-cell style
<vincenz> however it shouldn't be too much work to make such a function
<vincenz> if you want to work with lists a'la python. I'd look at arrays
<malte> oh :)
<malte> how does one slice an Array then?
<vincenz> rtm?
<malte> fair enough
<vincenz> Array.sub
* vincenz never uses the Array module much
<vincenz> but python lists are more like resizable arrays than lists
<malte> ah, thanks
<malte> vincenz, yeah, i was trying to implement such a function myself. but i got stuck :)
<vincenz> of course if you're planning on frequent inserts/appends, you'd better go for lists
<vincenz> arrays are more for when the 'list' is fixed-size
<malte> mk
<malte> btw, i was trying something like http://www.pastebin.com/117918
<malte> however it gives me the same slice every time :) i can't see what's wrong
<malte> and why isn't List.chop defined in the default toplever btw? i had to copy-paste it from the implementation
<vincenz> List is a module
<vincenz> so is Array
<vincenz> you can't possibly put everything in the toplevel
<vincenz> unless you get longer name functions
<vincenz> just do List.chop
<malte> i did that :) but i get "Unbound value List.chop"
<malte> other functions in the List module work however
<vincenz> oh, it's not exported!
<vincenz> hmm
<malte> oh
<malte> anyway, did you take a look at the pastebin?
<vincenz> yes, but it's quite confusing
<malte> when (if) it works, it'll prolly be mightily inefficient. but efficiency is not really vital right now
<malte> hrm :)
<vincenz> something better would be:
<vincenz> let rec splice m n l =
<vincenz> match l with
<vincenz> | [] -> []
<vincenz> let me type this out first
<malte> :)
<vincenz> you want b e?
<vincenz> or b l?
<vincenz> begin, end or begin, length
<malte> b e i suppose
<vincenz> ok
<vincenz> what if you do
<vincenz> 0 10 and your list is only 5 long?
<malte> then it'll return the whole list i think
<vincenz> ok
<malte> or complain? no, i think that's better
<vincenz> no that'll do
<malte> i mean, the return of the whole list
<vincenz> that shoul dwork
<vincenz> (not tested, just typed it out like that)
<vincenz> let me test
<vincenz> oops, some bugs
<vincenz> okido, almost got it :)
<vincenz> yip :)
<vincenz> ok
<vincenz> here is the output
<vincenz> tell me if you want a change
<malte> okay
<vincenz> splice 1 3 [0;1;2;3;4;5] -> [0; 1; 2]
<vincenz> splice (-1) 3 [0;1;2;3;4;5] -> [0; 1; 2]
<vincenz> splice (-1) 10 [0;1;2;3;4;5] -> [0; 1; 2; 3;4;5]
<vincenz> so it works with under and overbounds
<vincenz> and it selects [b,e)
<malte> perfect :) cheers
<malte> hm
<malte> the version in the pastebin doesn't seem to work
<malte> ah, thanks
malte has quit ["Lämnar"]
malte has joined #ocaml
<malte> vincenz, why do you use List.rev btw?
<vincenz> cause I build up lo in reverse fashion
<vincenz> basically I opop an element from the input list
<vincenz> and add it to the output list
<vincenz> so I need to reverse it in the end
<malte> ah, sorry.. i misread :)
<vincenz> let's say that m =0
<vincenz> oh, you got it
<malte> yeah
slickers has joined #ocaml
slickers has quit [Client Quit]
avlondono has joined #ocaml
karryall has quit ["tcho"]
vezenchio has joined #ocaml
Demitar has quit ["Bubbles..."]
Demitar has joined #ocaml
monochrom has joined #ocaml
<vincenz> malte: how's it going?
salo has joined #ocaml
<salo> greetings. anyone have experience building lablgl on os x? or know how to verify the proper installation of labltk?
<Demitar> salo, what is your specific problem?
<salo> File "togl.mli", line 4, characters 14-29:
<salo> Unbound type constructor Widget.widget
<salo> this is when building lablgl
<Demitar> And the compilation command?
<salo> simply make
<Demitar> Yes but what does make call?
<salo> ocamlmklib -o togl ml_togl.o Togl/togl.o -framework OpenGL -L/sw/lib -L/usr/X11R6/lib -lGL -lXmu
<salo> ocamlc.opt -c -w s -I +labltk -I ../../src togl.mli
<Demitar> And what does locate widget.cmi tell you?
<salo> no such file ... hmmm, that is the problem
<Demitar> How did you install ocaml?
<salo> binary package from inria
<salo> so i bet the right thing to do is compile ocaml from source
<Demitar> From the inria dl page (on OSX): "Note that this binary distribution is configured without the TCL/TK interface. If you want to use labltk, you will have to recompile OCaml yourself."
<Demitar> I think it's possible to compile lablgl without tk support if that's what you want though.
* salo is on the glide path
<salo> thanks Demitar, esp for not calling attention to the fact that i am dumb
<Demitar> Current knowledge is irrelevant. It's the willingness to learn which is valued.
<salo> bonus q: what do people use to edit ocaml source? particularily revised syntax
<monochrom> I use emacs currently. I have plans to use eclipse.
<Demitar> Don't know about revised syntax. I use emacs and others use vim.
<Demitar> With a bit of tweaking tuareg-mode is my very best friend. :)
<salo> eclipse is great, but the ocaml mode is barely there. i found an emacs mode for revised syntax but it is slightly broken
mrsolo has joined #ocaml
<malte> vincenz, fine, thanks :) (i forgot to thank you for the help btw!)
mflux has joined #ocaml
pango has quit ["Leaving"]
pango has joined #ocaml
_fab has quit [Remote closed the connection]
mrsolo has quit ["Leaving"]
CosmicRay has joined #ocaml
m3ga has joined #ocaml
karryall has joined #ocaml
m3ga has quit ["Client exiting"]
vezenchio has quit ["Deadpool still votes for Perot. Every time. Just in case."]
pgas has joined #ocaml
<pgas> hello, let's start by saying that I know nothing about ocaml
<pgas> I'm trying to compile ocaml for arm (zaurus), make world is ok but make bootstrap fails
<pgas> Fatal error: unknown C primitive `int_xor'
<pgas> Does this means something for someone?
<Smerdyakov> Is OCaml known to compile on ARM?
<pgas> Don't know ;)
<Smerdyakov> I would be surprised if they had picked that platform for a port.
<Smerdyakov> If no one has explicitly set things up to work there, it is very unlikely that someone who knows nothing about OCaml will be able to get it to work on that platform.
<Smerdyakov> It includes native code generators, for example.
<pgas> make world runs fine though
<Smerdyakov> I'm not sure what that means, in terms of which hurdles have been surmounted.
<Smerdyakov> But you could imagine that you might successfully compile a version of gcc that only targets x86, for example.
<Smerdyakov> This wouldn't mean that you had "gotten gcc to work for ARM."
<pgas> hmm I see
<Smerdyakov> Though I would expect that the bytecode version of OCaml probably works on ARM w/ few changes, if any.
<pgas> hmm I think this is the case, there is ocamlrun but no ocamlc in the boot dir thanks bye
pgas has quit ["Leaving"]
<vincenz> hi
<vincenz> re
<vincenz> ARM tends to be an easy platform
<Smerdyakov> Probably not easy enough for someone with no knowledge of the compiler's workings to target with a port.
<Smerdyakov> Ah. Useful link.
<CosmicRay> ocamlc works on ARM iirc
<CosmicRay> I think I have it on my zaurus
<CosmicRay> ocamlopt maybe not
<pango> Win9x is not very well supported, but who cares :)
<pango> for example Unix.rename is broken
<karryall> is it ?
CosmicRay has quit ["Client exiting"]
mlh has joined #ocaml
<pango> karryall: it uses FileMoveEx() or whatever API that's not implemented on that platform
<Smerdyakov> It doesn't go through Cygwin?
<karryall> pango: it seems to be checking the platform before doing so
<pango> karryall: but no Win9x API is good enough to emulate Unix.rename semantics
<karryall> ah maybe and I bet Unix.rename isn't the only one
<pango> at least that's one I stumbled upon
<pango> ah, they indeed improved rename.c
malte has quit ["Lämnar"]