<ggole>
They have staged computation stuff with a runtime representation of code, parameterised by type in exactly that way
Anarchos has joined #ocaml
alang_ has quit [Quit: Ex-Chat]
<ggole>
Haven't played with it in depth though
<vext01>
Drup: yep
<vext01>
does the problem still not stand?
<vext01>
how does the parser put stuff on the stack?
<vext01>
AFAIK i cant pass the stack *to* the parser
<vext01>
but the parser can call functions
<ggole>
If you mean generated parsers, they are just functions iirc
<ggole>
You can add another arg
alang_ has joined #ocaml
<vext01>
ggole: great! how?
<Drup>
oh, just put everything in a module and call it from the parser
<ggole>
Uh, hang on
<ggole>
It's been a while since I used the ocamlyacc stuff
<Drup>
vext01: my point is that you don't need to have real unevaluated code. when parsing your expression, you transform <bla> into a list.
<vext01>
Drup: you approach will return a list from the parser function itself?
<Drup>
you don't need to parse during evaluation of your stack
<Drup>
yes
<vext01>
that could also work
<vext01>
might be quite clean actually
<Anarchos>
Are float refs stored as Double_array_tag or zero tag block ?
<ggole>
Ah, seems I'm thinking of the lexer :(
<Drup>
vext01: You can still build your stack the regular way, just handle code inside < bla > in this way
<ggole>
It has a rule token = parse ... construct to which you can add args
<ggole>
If I remember rightly
<ggole>
Though I don't see why you need an entire parser to eat RPN code...
Neros has quit [Remote host closed the connection]
<Drup>
ggole: for the sake of experimentation ? :p
<ggole>
As good a reason as any!
<vext01>
ggole: because this is valid <1,2,3>,<<4>,5,<<6>>>,7
<ggole>
Ah, I see
<vext01>
you can nest unevaluated code
<vext01>
there goes the "RPN needs no parser" tagline
Neros has joined #ocaml
<Anarchos>
i have my answer : it is a 0-tagged block.
Drup has left #ocaml []
Drup has joined #ocaml
<Anarchos>
there seems to be a lack in the manual on this point (it speaks about records of floats stored with Double_array_tag)
Yoric has joined #ocaml
<Anarchos>
which is the case for records with more than 2 fields.
<ggole>
refs are polymorphic records, though
<ggole>
Arbitrary code needs to access the field without knowing that it is a float
paolooo has quit [Quit: Page closed]
<Anarchos>
ggole i test with "let a = ref 0.1" which is not really polymorphic ...
<Anarchos>
ggole but i get your point.
<ggole>
The double indirection does suck :(
<ggole>
OCaml isn't really tuned for numeric work.
gnuvince has joined #ocaml
Snark_ is now known as Snark
darkf has quit [Quit: Leaving]
ollehar has quit [Ping timeout: 272 seconds]
Yoric has quit [Ping timeout: 256 seconds]
<Anarchos>
ggole that is why array of doubles have a special representation
<ggole>
Yeah
<ggole>
And an array of 'as which happen to be doubles is much slower :(
<ggole>
That's the price of simple run time support for parametric polymorphism, I guess
raichoo has joined #ocaml
alang__ has joined #ocaml
pango_ is now known as pango
pngl has joined #ocaml
<pngl>
I have two modules A and B, each an implementation of the same set of functions. How can I selectively load one or the other in a single benchmarking script?
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
Anarchos has joined #ocaml
Yoric has joined #ocaml
emmanuelux has joined #ocaml
mcclurmc has quit [Ping timeout: 252 seconds]
ollehar has joined #ocaml
soulofpeace has quit [Ping timeout: 252 seconds]
Kakadu has quit [Quit: Konversation terminated!]
ontologiae has quit [Ping timeout: 256 seconds]
pngl has quit [Ping timeout: 245 seconds]
willy_ has quit [Read error: Connection reset by peer]
ollehar has quit [Ping timeout: 256 seconds]
Kakadu has joined #ocaml
mcclurmc has joined #ocaml
yacks has quit [Ping timeout: 255 seconds]
_andre has quit [Quit: leaving]
ttamttam has joined #ocaml
ottbot has quit [Ping timeout: 255 seconds]
ttamttam has left #ocaml []
zpe has quit [Remote host closed the connection]
dsheets has quit [Read error: Operation timed out]
Kakadu has quit [Read error: Connection reset by peer]
Kakadu has joined #ocaml
beginner42 has joined #ocaml
<beginner42>
i am trying to use postgresql, but i get this error
<beginner42>
ocamlfind: Error from package `threads': Missing -thread or -vmthread switch
yacks has joined #ocaml
wmeyer` has joined #ocaml
<wmeyer`>
morning
<beginner42>
wmeyer: very different time zone i guess
UncleVasya has joined #ocaml
raichoo has quit [Quit: leaving]
raichoo has joined #ocaml
ggole has quit []
Macuser__ has joined #ocaml
Macuser__ has quit [Quit: ChatZilla 0.9.90 [Firefox 20.0/20130326150557]]
weie has quit [Ping timeout: 268 seconds]
lusory has quit [Ping timeout: 252 seconds]
lusory has joined #ocaml
adahlberg has joined #ocaml
adahlberg has quit [Remote host closed the connection]
UncleVasya has quit [Quit: UncleVasya]
zpe has joined #ocaml
tobiasBora has joined #ocaml
<tobiasBora>
Hello !
<tobiasBora>
I've a little problem : I'd like to create a function to bild array of any dimension. The function takes in argument the number of cases in all new dimension :
<tobiasBora>
However I've an error with the last line : "Error: This expression has type 'a array array but an expression was expected of type 'a array"
<tobiasBora>
Could I contourn this error or this kind of initialisation is impossible in Ocaml ?
beginner42 has quit [Quit: irc2go]
<bernardofpc>
tobiasBora: I guess this is impossible "as is"
<bernardofpc>
your function must "type"
<bernardofpc>
so in particular its return type cannot depend on its arguments
<bernardofpc>
one way of doing that, though, is through algebraic types
<bernardofpc>
you can have 'a MyArray = OneDimArray of 'a array | MultDimArray of ('a MyArray) array
<tobiasBora>
bernardofpc: I hoped that the type only remember "array" and not things after...
<bernardofpc>
(or something like that, haven't tested that neither)
<bernardofpc>
you want to return 'x array from 'a array
<tobiasBora>
bernardofpc: And with this is it possible to translate this into an array ?
<bernardofpc>
what do you mean by "translate this into an array" ?
<tobiasBora>
I don't think it's possible but for exemple I create a pseudo array with this method, is it possible to create from this pseudo-array a real array ?
<tobiasBora>
(because a real array is easier to use)
<bernardofpc>
Oh
<bernardofpc>
I don't know
<bernardofpc>
how do you use a "multidim array" whose dimensions you don't know already ?
<bernardofpc>
you'd have to keep the list of dimensions somewhere, right ?
<tobiasBora>
bernardofpc: yes, I can keep it,
<tobiasBora>
but in the beginning it was just to have a generic method to create array of any dimension.
<bernardofpc>
yeah, I see
<bernardofpc>
don't think it is possible, but I don't think neither of any way of using a multidim array in OCaml without destructing dimensionwise as I've written
<bernardofpc>
(but I'm a noob)
<tobiasBora>
Ok I'll try to use the sum type method. Thanks :-)
wmeyer`` has joined #ocaml
<wmeyer``>
morning
<adrien>
moin
<wmeyer``>
haven't seen you for while adrien :-)
ontologiae has joined #ocaml
<adrien>
holidays ! \o/
<adrien>
brb, need to put something cold on my heel ='(
<wmeyer``>
why is it?
<wmeyer``>
great, you had your holidays
<adrien>
so now I can work again? :D
<adrien>
and worse than walking kilometers in mountains: wearing the shoes that you ought to wear for a wedding; it hurt ='(
Watcher7|off is now known as Watcher7
<gasche>
smondet: you actually don't usually need first-class modules to do that
<gasche>
if you have a functor Funct over the parametrized module Param
<gasche>
you can use local module binding
<gasche>
if ... then let module Benchmark = Funct(Param1) in Benchmark.run () else let module Benchmark = Funct(Param2) in Benchmark.run ()
<gasche>
(first-class modules can also be used of course, all I'm saying is that there are low-tech solutions as well)
<gasche>
hm
<gasche>
bernardofpc, tobiasBora: to some extent you can use existential types to have an array whose dimension depends on a dynamic input
<gasche>
that is
<gasche>
type 'a nested_array = | Array of 'a | Nested of 'a array nested_array
<gasche>
type unknown_dim_array = Some_dim : 'a nested_array -> unknown_dim_arry (* existential type in GADT *)
<gasche>
but then your unkown_dim_array is hard to use, as bernardofpc said
<gasche>
you can also use type-level integer tricks, if the dimension-polymorphic function is always called with statically known arguments
<tobiasBora>
I don't understand how existential types are used...
<gasche>
they're little used because they're hard to use: they represent situation where no type information is available, and in these situations you can't do much
<tobiasBora>
That's very interesting !
<gasche>
but you could, for example, get two unknown_dim_array, dynamically check that they have the same dimension, and then sum them together
<tobiasBora>
Um... powerfull !
<tobiasBora>
And what's GADT ?
<gasche>
yes, but you have to draw a line between "nice way to get more static guarantee" and "too clever for its own good"
<gasche>
Generalized Algebraic Datatype, a feature added in OCaml 4.00 that is one way to get existential types
<gasche>
(the other being first-class modules or some ugly encoding)
<gasche>
it's an "expert" feature and its error messages are *awful*, so not to be used lightly
<gasche>
(a bit like polymorphic variant, but maybe worse on the error message side)
pkrnj has joined #ocaml
<tobiasBora>
gasche: In fact I don't understand what add the unknow dim array. It seems to be for me like an alias of nested_array...
<gasche>
tobiasBora: the "existential type" comes from the fact that the 'a parameter in the argument type disappears from the defined type
<gasche>
so when you "open" an unkown_dim_array, you have no idea what this 'a may be
<gasche>
(and conversely, if you want to write a function that returns an array but cannot know statically what the 'a will be, you can wrap it with the Some_dim constructor)
Watcher7 is now known as Watcher7|off
<tobiasBora>
And the global structure (which seems to be hide) isn't a multidimentional array, but a sum type ?
malo has joined #ocaml
<gasche>
tobiasBora: 'a nested_array is another trick, but it's not a GADT
<gasche>
it's a multi-dimensional array, with one layer per dimension
structuralist has joined #ocaml
<tobiasBora>
How is it possible that only 1 arrow convert this structure in an array...
<tobiasBora>
I tried your lines, but I've an syntax error on the ":"
<gasche>
unknown_dim_array is 4.00
<tobiasBora>
Oh that's why ^^ And unknow_dim_array must be written like this or it can be replace by any name ?
<gasche>
of course, you can rename that
<tobiasBora>
Ok. I think that I'll wait a little bit (I register our discution for later) and study it when I've more time... Thanks a lot for this tips and your time !
<gasche>
I'm not actually advising you to use that
pkrnj has quit [Quit: Computer has gone to sleep.]
<gasche>
tends to get hairy messages, and ultimately you'll want to do something that outgrows the expressivity of the system
<tobiasBora>
I'll wait that my level is highter ^^ But that's nice to know that it exists !
<bernardofpc>
gasche> it's an "expert" feature and its error messages are *awful*, so not to be used lightly -> :D
<ousado>
for an any-dimensional array using these adanced features seems overkill to me
<bernardofpc>
gasche: I might think that some Array_with_dimensions : int list * (actual data) might be nice
<ousado>
exactly
<bernardofpc>
but then again OCaml-wise I'd write as a Sum-inductive type with int * (Array (n-1) )
* Anarchos
remembers an article about adding dimensions to array type in a pre-4.00 version of ocaml).
tobiasBora is now known as tobiasBorabe
tobiasBorabe is now known as tobiasBora
<tobiasBora>
bernardofpc: to avoid compute it every time we want to use it?
<tobiasBora>
And I've an other question (yes I love useless question :-° ) : when I create a huge list (1000000 elements for exemple) I've a stack overflow error. Is it possible to change the number of recursions before overflow ?
pkrnj has joined #ocaml
<bernardofpc>
probably depends on your memory and parameters of your interpreter / compiler+runtime
<ousado>
how do you create it?
<bernardofpc>
other useless question: are 'a array array efficient for access / modification ?
<bernardofpc>
(I mean, more than 'a list list, for example)
<Drup>
bernardofpc: since access is O(1) in an array and O(l) in a list .... yes.
<tobiasBora>
I found OCAMLRUNPARAM="l=10G" !
<wmeyer``>
adrien: but you had a rest!
<Drup>
tobiasBora: is it a problem if the list is reversed ? You could transform your function to be tail recursive
<Drup>
In fact, you could even generate the exact same list in a tail recursive way
<adrien>
wmeyer``: :-)
<tobiasBora>
Drup: It was only for a fast test so I don't mind if it's reversed. But I always heard about tail-recursive but I don't really know what it is...
Watcher7|off is now known as Watcher7
<Drup>
a function is tail recursive if the result of the recursive call is not used by something else and can be returned directly. Your function is not tail-recursive because the result of "init_list (n-1) init" is used by (::).
<Drup>
( :: )
<tobiasBora>
I see...
<tobiasBora>
And to make it tail_recursive I need to...
<tobiasBora>
use an aux function ?
<Drup>
yes
<ousado>
you have to avoid that it needs to do anything after returning from the recursive call
<ousado>
if you pass an empty list you can do it without another function
<Drup>
you could, in this case, use an accumulator as a function argument and fill the accumulator