<rwmjones>
normally if you need two arguments to a function you shouldn't use a pair
<felix^^>
so the , is generally a constructor for tuples?
<rwmjones>
yup
<rwmjones>
the brackets can usually be omitted
<felix^^>
i see, that's what confused me then :) was trying to apply an existing model of how to define a function and ocaml didn't complain but instead considered it a tuple. so the * is the respective sign for the tuple content?
<rwmjones>
* is used when printing types to indicate a tuple
<rwmjones>
so the value pair has type int * string
<felix^^>
alright, i think i understand then. thanks!
ttamttam has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
ttamttam has quit ["Leaving."]
ttamttam has joined #ocaml
Demitar has joined #ocaml
Tetsuo has joined #ocaml
asmanur has joined #ocaml
ppsmimou has joined #ocaml
ppsmimou has quit [Client Quit]
bluestorm_ has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
ttamttam has left #ocaml []
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
asmanur_ has joined #ocaml
jonathanv is now known as jonafan
loufoque has joined #ocaml
<loufoque>
when I have a record with a mutable field, does it mean the field is actually a pointer?
<rwmjones>
loufoque, no
<rwmjones>
if it's an int (or char) it'll be stored inline
<loufoque>
and if it's another record?
<rwmjones>
also a record with all float fields, even if mutable, is stored inline
<rwmjones>
ah right, if it's another record, then it's always a pointer
<rwmjones>
whether or not it's mutable doesn't matter basically
TFK has joined #ocaml
<loufoque>
you mean records are necessarily pointers?
<rwmjones>
loufoque, there's a function Obj.is_block which you can use to find out if something is a pointer or not
<rwmjones>
no records are allocated areas of memory
<rwmjones>
but things which refer to records are pointers!
<loufoque>
so if I put records in an array, my array actually containers pointers to those areas?
<rwmjones>
yup
<loufoque>
what if I don't want that?
<rwmjones>
use something like BigArray to memory-map your data
<rwmjones>
but basically if you want to use Array you're s.o.l
mikeX has joined #ocaml
<loufoque>
if I have type pos = {x : int; y : int} and type pair = { a = pos; b = pos; }, the fields of pair aren't inline?
asmanur has quit [Read error: 110 (Connection timed out)]
<loufoque>
a : pos; b : pos sorry
<asmanur_>
no
<loufoque>
if I use a tuple instead, will it be?
<asmanur_>
no
<asmanur_>
a tuple use the same representation in memory than a record
<loufoque>
so writing type pair { a_x : int; a_y : int; b_x : int; b_y : int} is actually more efficient?
<asmanur_>
(something like a C-array)
<asmanur_>
hum, I guess
<loufoque>
isn't that quite ridiculously annoying?
<bluestorm_>
do you have a good reason to care so much about memory efficiency ?
<rwmjones>
loufoque, no because other important things like persistence wouldn't work if the implementation was different
<rwmjones>
if you want an array of ints, use the BigArray array of ints
<loufoque>
bluestorm_: I'm doing image processing, and it's slow.
<loufoque>
(also it eats quite a lot of memory it seems)
<bluestorm_>
and the profiling shows that your pair is in the slow path of your code ?
<rwmjones>
loufoque, how about keeping your data as strings? they're basically opaque lumps of memory with fast access
<loufoque>
rwmjones: because my data structure is fairly more complicated, it contains 32-bit integers that index other parts of the image too.
<loufoque>
I'm not too sure using left shifts etc. everytime I want to get the int of the string is a good idea
<Tov_enst>
cannot refactor your structure into a high-level + low-level one ?
<rwmjones>
loufoque, how about writing a preprocessor to add an "inline record" modifier for records?
<rwmjones>
eg:
felix^^ has quit [Read error: 113 (No route to host)]
<rwmjones>
type foo = { inline a : pos ; inline b : pos }
<rwmjones>
which would just unfold the type of pos inline
<rwmjones>
and some convenience functions for access
<rwmjones>
or have an access operator as well in the preprocessor
<loufoque>
unfortunately, I know nothing about campl4
<loufoque>
so I can't write such a thing
<bluestorm_>
rwmjones: your suggestion is interesting
<bluestorm_>
but it's not really hmm, "user-friendly" ^^
<loufoque>
if my type is abstract, yet is an int
<loufoque>
will it be inlined?
<rwmjones>
loufoque, yes
<rwmjones>
the compiler knows all the types
<bluestorm_>
rwmjones: cross modules ?
<rwmjones>
yes of course, otherwise how would the compiler know how to code the allocation for a structure, unless it knew its type completely?
smimou has joined #ocaml
<bluestorm_>
hm, i thought the allocation code could be in the module object code, and thus be connected at linking time
TFK has quit [Read error: 110 (Connection timed out)]
CRathman has joined #ocaml
rickardg has quit [Read error: 110 (Connection timed out)]
ita has joined #ocaml
mikeX_ has joined #ocaml
psnively has joined #ocaml
mikeX has quit [Read error: 110 (Connection timed out)]
filp has joined #ocaml
EliasAmaral has quit [Read error: 101 (Network is unreachable)]
asmanur_ has quit [Read error: 110 (Connection timed out)]
Torment has joined #ocaml
psnively has quit []
hkBst has quit ["Konversation terminated!"]
ygrek has joined #ocaml
Jedai has quit [Read error: 110 (Connection timed out)]
ygrek has quit ["Leaving"]
ygrek has joined #ocaml
EliasAmaral has joined #ocaml
ttamttam has joined #ocaml
CRathman has quit ["ChatZilla 0.9.78.1 [Firefox 2.0.0.9/2007102514]"]
romanoffi has left #ocaml []
buluca has joined #ocaml
kelaouchi has joined #ocaml
ygrek has quit [Remote closed the connection]
\\ has quit [Remote closed the connection]
\\ has joined #ocaml
ygrek has joined #ocaml
ygrek has quit [Remote closed the connection]
filp has quit ["Bye"]
ita is now known as ita|zzz
ita|zzz has quit ["Hasta luego!"]
<loufoque>
how can I have the trace of an exception to debug it?
<pango_>
compile with -g, set OCAMLRUNPARAM='b' in environment
<pango_>
before 3.10, it also only works for bytecode
* loufoque
has 3.09
* loufoque
wonders why his distribution doesn't have a more recent version
RobertFischer has joined #ocaml
RobertFischer has quit [Client Quit]
Tetsuo has quit [Remote closed the connection]
Tetsuo has joined #ocaml
loufoque has quit ["Quitte"]
loufoque has joined #ocaml
<loufoque>
hmm, I just compiled ocaml 3.10 and lablgtk doesn't work anymore
<loufoque>
why do libraries get broken in compiler upgrades?
<flux>
the interface compatibility requirements are quite strict in ocaml
<flux>
that is: it doesn't accept any change
<flux>
I understand that's because that hasn't been researched that much, and it's a safe choice (so you won't be able to subvert the soundness of the type system)
bluestorm_ has quit ["Konversation terminated!"]
<flux>
although one would think that it should be possible to allow for example an interface that is purely a superset of an older one..
<loufoque>
well, breaking the C++ ABI a few times generated quite some fuss, people weren't happy at all
<loufoque>
yet ocaml people don't care?
<flux>
but there aren't shared ocaml libraries around, are there?
<flux>
so it doesn't matter that much
<flux>
basically just recompile all modules. and if you're using a distribution, that's done for you.
<flux>
of course, in C nothing prevents a library from changing int foo(int a, int b) into float foo(float a, char* b) between releases - and even C++ symbol mangling doesn't prevent changing the type of the return value of a function
<flux>
with ocaml, people like things to actually work once they compile :)
buluc1 has joined #ocaml
david_koontz has joined #ocaml
ttamttam has left #ocaml []
psnively has joined #ocaml
Mr_Awesome has quit ["aunt jemima is the devil!"]
mikeX__ has joined #ocaml
Tetsuo has quit ["Leaving"]
mikeX_ has quit [Read error: 101 (Network is unreachable)]