<adrien>
oh, btw, my issue with sexplib was a '\n' at the end of the string, which is fine if you read from a file with sexplib functions, but not if you tell sexplib to load from an in-memory string
<adrien>
(had used print_endline instead of print_string ...)
<thelema>
adrien: good find
infoe has joined #ocaml
<elehack>
anyone know of a camlp4 extension to generate construction functions from a type's constructors?
elehack has quit [Ping timeout: 240 seconds]
elehack has joined #ocaml
thatch has quit [Remote host closed the connection]
ymasory_ has joined #ocaml
myu2 has joined #ocaml
dgfitch has joined #ocaml
drunK has quit [Remote host closed the connection]
<avsm>
elehack: example?
<elehack>
type foo = Foo of int | Bar of string results in the functions 'foo: int -> foo' and 'bar: string -> foo' being define
<elehack>
although further coding has revealed that I don't really need it anymore.
thatch has joined #ocaml
<thelema>
elehack: pa_do will, IIRC
<thelema>
or maybe not - I can't find...
BiDOrD has quit [Ping timeout: 240 seconds]
<elehack>
thelema: yeah, I'm not seeing a reference to that feature in the pa-do page on ocamlcore forge.
<elehack>
Looks good except for one situation: as we approach 2.0 on master, we probably want to be able to cut new 1.x bugfix releases.
<elehack>
Should be easy to adapt by having an 'oldmaster' branch (with a nicer name)
Edward has quit []
<elehack>
I've dropped a note in the page to that effect, and that should do until we hit that situation.
myu2 has quit [Remote host closed the connection]
Amorphous has quit [Ping timeout: 272 seconds]
ymasory_ has quit [Ping timeout: 260 seconds]
Amorphous has joined #ocaml
mrvn has quit [Read error: Operation timed out]
mrvn has joined #ocaml
elehack has quit [Quit: Farewell, programs.]
avsm has quit [Quit: Leaving.]
ymasory_ has joined #ocaml
myu2 has joined #ocaml
myu2 has quit [Remote host closed the connection]
myu2 has joined #ocaml
ulfdoz has joined #ocaml
ymasory_ has quit [Ping timeout: 240 seconds]
Associat0r has joined #ocaml
ikaros has joined #ocaml
Yoric has joined #ocaml
lamawithonel has joined #ocaml
ikaros has quit [Remote host closed the connection]
ulfdoz has quit [Ping timeout: 240 seconds]
BiDOrD has joined #ocaml
ttamttam has joined #ocaml
edwin has joined #ocaml
naufraghi has joined #ocaml
BiDOrD has quit [Ping timeout: 272 seconds]
Yoric has quit [Quit: Yoric]
jado has joined #ocaml
myu2 has quit [Remote host closed the connection]
<adrien>
morning
<adrien>
thelema: thanks, hard to believe a \n at the end of the string was the problem
<adrien>
also, for anything that constructs values from type definitions, I'd take a look at extensions relying on type-conv
ftrvxmtrx has quit [Quit: Leaving]
accel has joined #ocaml
<accel>
is there a pcm/sound syntehsis library in ocaml?
<adrien>
I know of sound file handling libraries (for the encoding e.g.) butnot sure about synthesis, which features do you want? what would be the input?
<accel>
my ocaml code would output a pcm on the fly
<accel>
i want that pcm to be played by my speakers
<accel>
I'm on ubuntu 10.10
<adrien>
so more sound playing? there are bindings to various sound interfaces, a simple one is libao, it should be perfect unless you need precise control over the audio interface
<accel>
i guess this would be the unit test:
<accel>
I want something where I can use ocaml to generate a sine curve, pipe it to the sound card,
<accel>
and get a zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
<adrien>
the sine curve-generation is not something I ever tried and I don't know what would be useful, maybe someone else does however
<accel>
when shoudl i use records, and when shoudl I use objects?
<accel>
oh, generating the sine curve is trivial
<accel>
just a for loop + store it in an array
<accel>
it's going from the sine curve to a constant humming on the soudn card
<accel>
that requires libraries
<adrien>
ok, then libao
<accel>
cool; thanks
<adrien>
=)
<accel>
how about tuples vs objects?
<adrien>
tuples or records? ;-)
<accel>
s/tuples/records/
eye-scuzzy has quit [Quit: leaving]
<adrien>
for records vs objects: you'd use records by default unless you need some features of objects
eye-scuzzy has joined #ocaml
<accel>
so this thing about records needing unique names
<adrien>
namely, inheritance, the ability to share fieldnames
<accel>
if I want to have a vec3: x, y, z; and a quaternion: w, x, y, z
<adrien>
heh
<accel>
do I need to stick them in different modules ?
<adrien>
if you want to keep these names, yeah
<accel>
hmm; or I can use objects and ahve them in the same module?
jado has quit [Read error: Operation timed out]
ygrek has joined #ocaml
<adrien>
if you always hide the manipulation of the records inside functions, you could declare the {x;y;z} and corresponding functions at first, and then everything related to {x;y;z;w}, but that's not very clean
<accel>
crap; time to read about the module system
<adrien>
you oculd use objects but I'm not sure it's a very good solution: you won't do the same operation on 'x' if it's a triplet or quaternion
jado has joined #ocaml
<f[x]>
accel, savonet has primitives for sound synthesis
<f[x]>
just use x y z w and w = 1. for vectors
<adrien>
accel: 1- each .ml file defines a module, 2- you can build a module inside another one (for instance inside a file) with: module Quat = struct [yourcode] end
<adrien>
heh, true, even better :-)
* adrien
knows nothing about sound
<accel>
here's somethign simpler that I don't understand.
<accel>
in OCaml, when I create more complicated types from the basic types
<accel>
should I make them out of records, tuples, or objects?
<flux>
for simple cases tuples can do, if you have more fields or a risk of mixing the type with other tuples, a record and if you need the polymorphism or syntax candy objects provide, objects
<adrien>
we tend to tell people not to rush to objects
<flux>
in my view oop in ocaml is an advanced subject
<accel>
more advanced than in scheme?
<adrien>
and as flux said, records are good when you have more fields because fields are named
<flux>
scheme has objects?
<accel>
build from closures
<accel>
but very early oh, one runs intot he problem of duplicate field names
<accel>
which pretty much forces objects
<flux>
well, it's the static typing that makes them 'advanced' in ocaml I'd say
<flux>
and scheme doesn't have that, so perhaps it's not a valid comparison
<accel>
what's a good tutorial on ocaml's object system, by examples?
<flux>
do note that if you have a record of floats, they get special attention from the compiler
<accel>
in a good (more optimized) or bad (what would it be?) way ?
<flux>
in a good way
<accel>
as in sse2/sse3 operations?
<flux>
nope, but there's less boxing going on
<accel>
what?
<accel>
boxing?
<accel>
hmm, I thoght static typing would eliminate most of that
<flux>
boxing = putting data behind a pointer in the name of uniform data representation
ygrek has quit [Ping timeout: 240 seconds]
<accel>
say I want the equi of struct Quat { float x, y, z; } <-- is there anyway to set this up in ocaml? I don't want: struct Quat { float *x, *y, *z; }
<flux>
well, the problem with for example tuples is that if you have tuple of type 'a * 'b, it can be passed into a function that accepts float * float
<adrien>
I don't think I'll ever make any interface with React or a similar library, that's just too much pain for too many bugs
<flux>
and while float * float could be optimized internally, it would require converting the representations at each border
<adrien>
accel: structs of only floats store the floats unboxed iirc, so you don't get much of it (I guess you have the boxing for the struct itself but that's it)
<flux>
accel, the equivalent would be type a = { x : float; y : float; z : float } or alternatively type a = float array, which is represented the same way
<flux>
(of course you need bounds checking on the latter etc)
* accel
thinkgs
<flux>
if you put in something else than a float, though, you lose the optimization
<flux>
so basically it's an optimization for mathematical code
<accel>
flux: how can I put in anything else other than a float, wouldn't taht be a compile error?
<mrvn>
accel: type quat = { x:float; y:float; z:float; } is represented as one block of memory of type float array and length 3 floats. A float * float * float tuple (1.0, 2.0, 3.0) on the other hand is a block of memory containing 3 pointers to floats.
<flux>
accel, I mean if you add another non-float field
<flux>
but perhaps you don't need to worry about it (a lot) until you find that the performance isn't sufficient
<adrien>
accel: for the record, not for the array: { x : float; y : float; z : float; id : int }
<mrvn>
flux: hey, don't explain the same thing I'm typing. :=
<accel>
what's the motivation behind these layers of indirection?
<flux>
accel, uniform data representation
<accel>
is it because ocaml only has like 29 bits to store something
<mrvn>
accel: the GC has to know the type of each entry
<accel>
so for int's, it's 29 bit ints rather than 32 bit ints
<accel>
and for floats, we have to store pointers rather than 32 bit floats?
<adrien>
no, 31 or 63
<mrvn>
accel: 31bit actually
<flux>
accel, ocaml doesn't have C floats, actually, only C doubles
<accel>
how does ocaml get 50% of the performance of C? :-)
<adrien>
and Int64 and Int32 are available
<flux>
so they wouldn't fit into 32 bit anyway
<accel>
this indirection looks like it'd screw up memory coherence
<adrien>
accel: fairy dust I heard :P
<flux>
well, I think it's very likely that the data pointed is quite near the record itself
<accel>
deos the optimizing compiler unbox this sstuff?
<mrvn>
accel: there is no optimizing compiler. :(( But yes, some unboxing is done.
<accel>
hmm; suppose I have in C like: struct Vec{ float x, y, z; }; Vec my_vec[100];
<accel>
is there a way I can generate this in ocaml, so the my_vec is 300 consectuve floats in memory?
* adrien
wouldn't mind an ocaml<->hlvm interface, maybe more automated than the ocaml<->C one)
<mrvn>
accel: let vec_array = Array.make 300 0.0
BiDOrD has joined #ocaml
<accel>
mrvn: that seems like losing laywers of abstraction
<mrvn>
accel: You can't have an array 100 "struct Vec" that will be consecutive in memory.
<adrien>
for 300 it shouldn't be a problem but for more you're going to get bigger objects, and bigger objects to more around
<flux>
mrvn, hm, so the whole array is unboxed in that case?
<mrvn>
accel: each "struct Vec" needs one word header for the GC metadata. You get that inbetween elements then.
<accel>
ah; the reason is that ocaml's gc is a mark & sweep + move around?
<mrvn>
flux: the whole array would be one big box.
<adrien>
because for that one, you already have 300 doubles in memory at once, it becomes non negligible* for cache, and can in turn be a perf issue
<mrvn>
accel: yes
<flux>
mrvn, nice, I didn't know that
<mrvn>
flux: special case of an array of floats.
<accel>
alright; thanks I don't like the sound of all this; but I suspect i'm way in premature optimization already anyway
<adrien>
=)
<flux>
mrvn, ah, nevermind. I was thinking the case of Array.make 300 { x = 0.0; y = 0.0; z = 0.0; }
<flux>
and that isn't unboxed, right?
<mrvn>
accel: don't worry too much about this. By copying pointer around instead of structures you can safe a lot of time too.
<mrvn>
flux: no. but each record itself is only one box.
<mrvn>
accel: For example say you have your array of 100 Vectors and now you want to sort them by magnitude. Then you only move the pointer around while in C you would have to copy each vector.
<accel>
yeah
<accel>
but suppose X = array of 300 Vec3, Y = array of 300 Vec3; Z = elemwise X + Y; if they're all consecutive in memory, it'd be much faster
<adrien>
if you can keep the whole structure in cache, but if the cpu has to move the whole beast around, that will incur a big slowdown
<accel>
#type ratio = {num: int; denum: int};;
ttamttam has quit [Read error: Operation timed out]
<accel>
#type number = Int of int | Float of float | Error;;
<accel>
there are the two ways, besides objects, to define new types right?
<accel>
the first = record, the latter = variant
<mrvn>
accel: They will be consecutive in memory when the array is created. And I think the GC keeps the consecutive if they are only referenced from the array. They will have the GC header word inbetween them so they are a bit bigger than C.
<accel>
mrvn: so basically all ocaml arrays, except for specialized arrays, are arrays of pointers ?
<mrvn>
accel: and objects are mostly the exception.
<accel>
mrvn: objects are exception to what?
<mrvn>
accel: no. All (except a few exceptions) are arrays of values. A value for a float is a pointer to it.
<mrvn>
accel: most people don't use obejcts.
<mrvn>
accel: Some things are encoded directly into a value. Integers are values with bit 0 == 1. type A | B | C is encoded as integers 0, 1 or 2. () and None, true, false and so on are also directly in the value.
<accel>
what is the definition of an ocaml 'value' ?
<mrvn>
Anything to big to fit in the value is a pointer.
<accel>
it soudns like a reference
<accel>
(i.e. value == reference)
<mrvn>
accel: no, how is an integer a reference?
<accel>
except integer, None, true, false, ()
<accel>
I guess basically, ocaml gives me _no control_ over memory layout
<mrvn>
accel: right. Except the Bigarray module has some.
<mrvn>
accel: If you have ocaml-doc installed then read file:///usr/share/doc/ocaml/docs/ocaml.html/manual032.html
<mrvn>
Chapter 18 Interfacing C with Objective Caml
<mrvn>
Or google for the online version.
jado has quit [Read error: Operation timed out]
<mrvn>
accel: if you need a specific memory layout you could use a bigarray to store the floats and write a module around it to make it look like an array of struct Vec.
<accel>
interesting
<accel>
how do the janestreet people not have concerns with this
<accel>
they ust want manual layout
<mrvn>
Because you would only do this if you need to interface the array with C.
<mrvn>
Instead of bigarray a simple float array works too.
<accel>
can a big array be a member of a record/objet?
_andre has joined #ocaml
Znudzon has joined #ocaml
ftrvxmtrx has joined #ocaml
accel has quit [Quit: leaving]
Znudzon has quit [Quit: Relax, its only ONES and ZEROS!]
Znudzon has joined #ocaml
kani has joined #ocaml
<mrvn>
Znudzon: But the ONES are out to get me. How can I relax?
Vinnipeg has joined #ocaml
myu2 has joined #ocaml
decaf has quit [Quit: Leaving]
BiDOrD has quit [Read error: Operation timed out]
avsm has joined #ocaml
Vinnipeg has quit [Remote host closed the connection]
boscop has joined #ocaml
avsm1 has joined #ocaml
hto has quit [Quit: Lost terminal]
avsm has quit [Read error: Operation timed out]
ttamttam has joined #ocaml
hto has joined #ocaml
hto has quit [Client Quit]
avsm1 has quit [Quit: Leaving.]
avsm has joined #ocaml
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
hto has quit [Client Quit]
willb1 has joined #ocaml
hcarty has quit [*.net *.split]
willb has quit [*.net *.split]
mbac has quit [*.net *.split]
bacam has quit [*.net *.split]
dgfitch has quit [*.net *.split]
jlouis has quit [*.net *.split]
jonathandav has quit [*.net *.split]
Asmadeus has quit [*.net *.split]
hto has joined #ocaml
dgfitch has joined #ocaml
hto has quit [Client Quit]
jlouis has joined #ocaml
Asmadeus has joined #ocaml
jonathandav has joined #ocaml
hcarty has joined #ocaml
bacam has joined #ocaml
mbac has joined #ocaml
boscop_ has joined #ocaml
rwmjones_ has joined #ocaml
ymasory_ has joined #ocaml
mrvn_ has joined #ocaml
rwmjones has quit [Ping timeout: 240 seconds]
Associat0r has quit [Ping timeout: 240 seconds]
thatch has quit [Ping timeout: 240 seconds]
boscop has quit [Ping timeout: 240 seconds]
ymasory has quit [Ping timeout: 240 seconds]
thatch has joined #ocaml
mrvn has quit [Ping timeout: 240 seconds]
avsm has quit [Ping timeout: 272 seconds]
hto has joined #ocaml
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
hto has quit [Client Quit]
avsm has joined #ocaml
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
hto has quit [Client Quit]
xl0 has quit [Ping timeout: 260 seconds]
hto has joined #ocaml
xl0 has joined #ocaml
drunK has joined #ocaml
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
boscop_ is now known as boscop
hto has quit [Client Quit]
hto has joined #ocaml
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
hto has quit [Client Quit]
hto has joined #ocaml
hto_ has joined #ocaml
cyanure has joined #ocaml
<cyanure>
Hi guys
<cyanure>
DO anyone know if there is a simple way to use camlp5 with ocamlbuild ?
<edwin>
in _tags: pp(camlp5 ...camlp5args)
<edwin>
won't that work?
decaf has joined #ocaml
hto_ has quit [Quit: Lost terminal]
hto has quit [Quit: Lost terminal]
<cyanure>
I don't really know, If i extend the syntax myself, will the new syntax files be complied automatically ?
maurer_ has joined #ocaml
<edwin>
I don't know how dependencies work when you use your own syntax extension
cyanure has quit [Remote host closed the connection]
<edwin>
but you can try looking at some examples that use camlp4, same should apply to camlp5
oriba has joined #ocaml
smerz has quit [Remote host closed the connection]
thatch has quit [Quit: Konversation terminated!]
thatch__ has joined #ocaml
hto has joined #ocaml
CoryDambach has quit [Quit: Leaving]
quantumelixir has joined #ocaml
thatch__ has quit [Remote host closed the connection]
BiDOrD has joined #ocaml
ikaros has joined #ocaml
rwmjones_ is now known as rwmjones
BiDOrD has quit [Ping timeout: 276 seconds]
Yoric has quit [Read error: Connection reset by peer]
ttamttam has left #ocaml []
Yoric has joined #ocaml
BiDOrD has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
Znudzon has quit [Quit: IceChat - Keeping PC's cool since 2000]
BiDOrD has quit [Ping timeout: 245 seconds]
avsm has quit [Quit: Leaving.]
BiDOrD has joined #ocaml
naufraghi has quit [Quit: naufraghi]
BiDOrD has quit [Ping timeout: 245 seconds]
elehack has joined #ocaml
jonafan__ is now known as jonafan
willb1 has quit [Ping timeout: 250 seconds]
rmitt__ has joined #ocaml
willb1 has joined #ocaml
ftrvxmtrx has joined #ocaml
Yoric has quit [Quit: Yoric]
rmitt__ has quit [Quit: Page closed]
ygrek has joined #ocaml
BiDOrD has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
fabjan has quit [Remote host closed the connection]
ulfdoz has joined #ocaml
Yoric has joined #ocaml
yezariaely has joined #ocaml
yezariaely has left #ocaml []
theDroggl has quit [Remote host closed the connection]
ccasin has joined #ocaml
Modius has joined #ocaml
Modius_ has joined #ocaml
Modius_ has quit [Read error: Connection reset by peer]
_andre has quit [Quit: leaving]
mnabil has joined #ocaml
ulfdoz has quit [Ping timeout: 265 seconds]
Anarchos has joined #ocaml
mnabil has quit [Remote host closed the connection]
LeNsTR has quit [Quit: LeNsTR]
LeNsTR has joined #ocaml
LeNsTR has quit [Changing host]
LeNsTR has joined #ocaml
edwin has quit [Remote host closed the connection]
lpereira has joined #ocaml
LeNsTR has quit [Read error: Connection reset by peer]
onefriedrice has joined #ocaml
LeNsTR has joined #ocaml
LeNsTR has quit [Changing host]
LeNsTR has joined #ocaml
quantumelixir has quit [Ping timeout: 240 seconds]
quantumelixir has joined #ocaml
elehack has quit [Quit: Leaving]
LeNsTR has quit [Read error: Connection reset by peer]
LeNsTR has joined #ocaml
LeNsTR has quit [Changing host]
LeNsTR has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
LeNsTR has quit [Read error: Connection reset by peer]
LeNsTR has joined #ocaml
LeNsTR has quit [Changing host]
LeNsTR has joined #ocaml
LeNsTR has quit [Read error: Connection reset by peer]
decaf has quit [Quit: Leaving]
Yoric has quit [Quit: Yoric]
decaf has joined #ocaml
LeNsTR has joined #ocaml
LeNsTR has quit [Changing host]
LeNsTR has joined #ocaml
onefriedrice has quit [Quit: leaving]
LeNsTR has quit [Read error: Connection reset by peer]
ikaros has quit [Quit: Leave the magic to Houdini]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
metasyntax has joined #ocaml
lpereira has quit [Quit: Leaving.]
accel has joined #ocaml
<accel>
is the following correct? Camlp5 = old preprocessor, Camlp4 = current preprocessor? the numbering confusessss me
Edward_ has joined #ocaml
<alpounet>
camlp5 is more recent than camlp4
smerz has joined #ocaml
<mfp>
accel: camlp5 is a branch derived from camlp4 pre-3.10
LeNsTR has joined #ocaml
<accel>
so it doesn't work with ocaml 3.11/3.12 ?
<mfp>
accel: typically, camlp5 is used to build older code (that used to compile with camlp4 before OCaml 3.10)
<mfp>
it does work with newer OCaml versions
<accel>
(according to wikipedia:)
<accel>
Camlp4 is part of the official OCaml distribution which is developed at the INRIA. Its original author is Daniel de Rauglaudre. OCaml version 3.10.0, released in May 2007, introduced a significantly modified and backwards-incompatible version of Camlp4. De Rauglaudre maintains a separate backwards-compatible version, which has been renamed Camlp5. All of the examples below are for Camlp5 or the previous version of Camlp4 (versions 3.09 and prior).
<accel>
so basically, camlp5 = for older code; camlp4 = current + latest + greatest ?
accel has quit [Quit: leaving]
<mfp>
basically, yes; some people might prefer camlp5 (old camlp4 style) for new developments, though
thelema_ has joined #ocaml
<mfp>
I don't know if anybody is actually using camlp5 for new stuff