huxley.openprojects.net changed the topic of #ocaml to: www.ocaml.org
pHa has quit ["O_O"]
pHa has joined #ocaml
Taaus has quit [Read error: 104 (Connection reset by peer)]
Taaus has joined #ocaml
graydon has quit []
pHa has quit ["Reconnecting"]
pHa has joined #ocaml
<mellum>
Anybody knows a bit about the internal representation of OCaml?
<jemfinch_>
what do you mean?
<mellum>
I want to know why ints are tagged with a 1, and not with a 0 lower bit.
<mellum>
Because the latter would be easier to implement IMHO.
<jemfinch_>
because of machine alignment restrictions.
<jemfinch_>
the tag is to differentiate ints from pointers.
<jemfinch_>
pointers have to be aligned on 4 byte boundaries, which means the lower two bits will be 0 on every pointer.
<jemfinch_>
and thus, ints have to be tagged with a 1 to let the garbage collector know they're ints and not pointers.
jemfinch_ is now known as jemfinch
<mellum>
Yes, but the choice which tag denotes what is somewhat arbitrary... one could also tag ints with 0 and pointers with 1
<mellum>
then one could do integer addition directly
<jemfinch>
you could, but you'd have you mask a pointer on every single dereference.
<mellum>
no, you can use a constant offset of -1, which costs absolutely nothing.
<mellum>
On RISC, that is.
<jemfinch>
it would degrade performance by a significant amount -- pointer dereferencing happens *far* more often than integer arithmetic.
<jemfinch>
well, not every machine is RISC, is it? :)
<jemfinch>
in fact, most machines that O'Caml runs on aren't RISC -- they're CISC.
<mellum>
But most *architectures* are RISC, and i386 is a pretty new port IIRC.
<jemfinch>
integer arithmetic probably isn't a priority for the O'Caml folks, and rightly so -- not very many people at all do it.
<jemfinch>
x86 might even be a recent port (I don't know) but the majority of the machines O'Caml runs on are x86.
<mellum>
One could then make this choice dependend on the architecture. Shouldn't be all that difficult...
<jemfinch>
I think you're really making a rather large deal about something that doesn't really matter :)
<jemfinch>
I think tagging pointers instead of ints would, even with that RISC thing, be much more complicated than what they do now.
<jemfinch>
you'd still have to tag every single pointer created -- and that would seriously degrade performance much more than tagging ints does.
<mellum>
Well, that's one opcode per allocation. I'd expect there are a lot more integer ops than allocations.
<jemfinch>
aside from that, it would make integration with C much harder, since (and I'm making assumptions about the behavior of the RISC pointer shift thingy) pointers created on the stack in C code couldn't be derefenced directly (you'd have to increment them first, and C being what it is, that would require a cast to a void* [since otherwise, an increment increases the pointer by the size of what it points to])
<jemfinch>
I'd expect there are more allocations than integer ops, actually.
<jemfinch>
every cons allocates 3 pointers.
<mellum>
Well, dunno... an allocation probably takes a few ten cycles anyway, so it wouldn't matter all that much
<jemfinch>
but that doesn't change that there are probably more allocations than integer ops, I think :)
jao has quit [Read error: 113 (No route to host)]
<jemfinch>
I want compile time garbage collection in O'Caml.
<jemfinch>
(or sml-nj)
pHa has quit [Read error: 104 (Connection reset by peer)]
pHa has joined #ocaml
Taaus has quit ["leaving"]
Taaus has joined #ocaml
samx has joined #ocaml
smkl has quit [Read error: 104 (Connection reset by peer)]
graydon has joined #ocaml
mellum has quit [Read error: 110 (Connection timed out)]
smkl has joined #ocaml
mellum has joined #ocaml
samx has quit [carter.openprojects.net irc.openprojects.net]
mellum has quit [carter.openprojects.net irc.openprojects.net]
smkl has quit [carter.openprojects.net irc.openprojects.net]
pHa has quit [carter.openprojects.net irc.openprojects.net]
mellum has joined #ocaml
smkl has joined #ocaml
samx has joined #ocaml
pHa has joined #ocaml
samx has quit [carter.openprojects.net irc.openprojects.net]
mellum has quit [carter.openprojects.net irc.openprojects.net]
smkl has quit [carter.openprojects.net irc.openprojects.net]
pHa has quit [carter.openprojects.net irc.openprojects.net]
mellum has joined #ocaml
smkl has joined #ocaml
samx has joined #ocaml
pHa has joined #ocaml
graydon has quit []
graydon has joined #ocaml
<jemfinch>
anyone here?
<Taaus>
Umm... I'm here... For a short while, anyway :)
<jemfinch>
do you know about quotations?
<jemfinch>
(and antiquotations)
<Taaus>
Hmm... I'm not sure... Can you explain what they are? :)
<jemfinch>
nope, that's why I was going to ask you :)
<jemfinch>
someone said ruby had a generic api for iteration, and I didn't think it did.
<Taaus>
Well, it does... Using mix-ins from module Enumerable, IIRC :)
<jemfinch>
oh well.
<jemfinch>
I probably dislike Ruby more than I dislike any other language.
<Taaus>
Heh, well... You sure don't seem very knowledgeable about it ;)
<jemfinch>
I couldn't program in it, that's true.
<Taaus>
Let's stay away from the whole Ruby deal this time...
<jemfinch>
:)
<jemfinch>
anyway, (anti)quotations seem to be some sort of powerful preprocessor.
<Taaus>
Yeah.
<samx>
perhaps something similar to lisp quotes and unquotes ?
<samx>
and quasiquotes
<Taaus>
I admit total ignorance af far as lisp is concerned... I'm afraid of parentheses ;)
<Taaus>
af->as
<jemfinch>
:)
<jemfinch>
I definitely think when I get back to programming (which won't be for awhile, I'm killed with other work) I'll be converting to SML.
<Taaus>
Okay...
<Taaus>
I have precious little time for programming myself...
<jemfinch>
yeah, it stinks, doesn't it?
<Taaus>
Nono, I love studying music... If I wanted to program more, I'd study CS, but there are various reasons why I don't do that. :)
samx has quit [carter.openprojects.net irc.openprojects.net]
samx has joined #ocaml
<Taaus>
I wonder how difficult it would be to implement a BF parser in O'Caml...
<samx>
so, why are you looking at going to sml?
<jemfinch>
BF?
<Taaus>
Uhhh... Interpreter, not parser..
<Taaus>
BF = BrainF*ck... King of the Turing tarpits :)
<jemfinch>
hehe...it shouldn't be too hard :)
<jemfinch>
heck, you could write it as a compiler pretty easily.
<jemfinch>
samx: well, sml-nj in particular.
<jemfinch>
it has first-class continuations, something I've always wanted to play around with.
<jemfinch>
it also has quotations/antiquotations, which seem interesting.
<samx>
checked camlp4 ? i believe it has quotations
<jemfinch>
I never liked classes in ML, so I don't feel like I'm losing much in that regard.
<jemfinch>
and a lot more research seems to go on in SML -- stuff that'll be interesting to play with. Concurrent ML, Ckit, compile-time garbage collection, etc.
<jemfinch>
it also is a bit more focused on safety -- for instance, the functions that convert from strings all return NONE or Some <type>, instead of just returning <type> and raising an exception on failure.
<samx>
the research features are pretty implementation dependant.. i don't think sml/nj e.g. has regions
<jemfinch>
no, sml-nj doesn't.
<jemfinch>
it's mlkit that does that.
<jemfinch>
I don't know, it just seems a bit more interesting than O'Caml.
<jemfinch>
I don't doubt there are disadvantages (the classes might be useful sometimes; O'Caml has a tighter Unix module, and easier integration with C, etc.)
<samx>
yes, interesting implementations. but pretty much come with the same problems as ocaml
<jemfinch>
but for what I want to do, I think SML will provide a better environment.
<Taaus>
What is it you want to do?
<mellum>
Hmm, some guy here who was at a conference last week says SML is dead, and most people convert to the CAML branch.
<jemfinch>
I pretty much just write irc bots :)
<Taaus>
Hehehe, that's what I thought ;)
<jemfinch>
well, SML still has a stronger hold on universities.
<jemfinch>
(and in commerce)
<samx>
mellum: sml and caml are both pretty research languages, so if you are considering it from the users point a view, both sml and ocaml are dead
<samx>
jem: stronger hold in commerce ?
<jemfinch>
samx: well, there at least has been a commercial implementation of SML :)
<samx>
jem, yeah.. long time ago, and it was discontinued a long time ago too :-)
<jemfinch>
well, I still like SML's safety features.
<jemfinch>
and sml-nj at least is still actively developed.
<jemfinch>
samx: do you know much about mlkit's regions and compile-time garbage collection?
<jemfinch>
specifically, why it's not implemented in other languages -- are there disadvantages to it?
<samx>
so is ocaml.. but looks like most sml people are looking at abandoning sml to a new 'sml' type language.. thought as they are researchers, i'm sure that'll take 10 years before anything really happens :-)
<samx>
jem, nope, not really. but after seeing that even with the regions, it's compiled code is slower that ocaml or some other sml implementations, i wonder...
<jemfinch>
well, I don't think much work has gone into optimizing mlkit like the work that's gone into sml-nj or ocaml.
<samx>
jem, but if you try out mlkit or look into regions, please tell me too ;-)
<jemfinch>
samx: I can't, I don't run linux :)
<Taaus>
jemfinch: You could always switch to Haskell and mess with monads... (Yet another subject of which I know absolutely nothing ;)
<jemfinch>
Taaus: I could, but that just doesn't seem all that interesting.
<Taaus>
Hehe, I can't disagree with that :)
<jemfinch>
first class continuations I find much more interesting :)
<Taaus>
... Right...
<Taaus>
;)
<samx>
there isn't a way to init a field in a record type with a pointer to itself, is there? That is, something like ( { my_record = r } as r)
<jemfinch>
no, I don't think so.
<jemfinch>
you could use Obj.magic and then set the point appropriately, though.
<jemfinch>
let r = { my_record = Obj.magic () }; r.my_record <- r; r;;
<jemfinch>
that might work.
<samx>
what does Obj.magic actually do? I've never used it
<mellum>
it's magic :)
<mellum>
A cast operator.
<mellum>
It does nothing except fooling the type system.
<samx>
so, 'Obj.magic ()' would cast the value unit to what ever the inferred type was, in the above?
<samx>
ok, played a bit with it on the top level, got it to dump a core etc.. but i think i got the idea pretty much now :-)
pHa has quit ["O_O"]
pHa has joined #ocaml
pHa has quit ["Reconnecting"]
pHa has joined #ocaml
Taaus has quit [Remote closed the connection]
Taaus has joined #ocaml
pHa_ has joined #ocaml
graydon has quit [Connection timed out]
pHa has quit [Connection timed out]
graydon has joined #ocaml
samx has quit [carter.openprojects.net irc.openprojects.net]
mellum has quit [carter.openprojects.net irc.openprojects.net]
Taaus has quit [Read error: 104 (Connection reset by peer)]
graydon has quit [carter.openprojects.net irc.openprojects.net]
pHa_ has quit [carter.openprojects.net irc.openprojects.net]
smkl has quit [carter.openprojects.net irc.openprojects.net]