vezenchio has quit [Read error: 110 (Connection timed out)]
pango has quit [Nick collision from services.]
pango_ has joined #ocaml
Riastradh has joined #ocaml
clog has joined #ocaml
patatof has joined #ocaml
<patatof>
hi
<patatof>
can anybody tell me how good is Ocaml RTTI versus CPP RTTI? And something about type inference?
salo has joined #ocaml
<mellum>
patatof: what is CPP?
<Submarine>
there's little RTTI in Ocaml
<patatof>
C++
<Submarine>
there's only enough to run the GC and serialization
<mellum>
I don't see any need for more, though.
<salo>
is it possible to define a type with restricted range of values, such as the natural numbers?
<mellum>
salo: you mean a restricted range *of* the natural numbers?
<salo>
i mean to define the naturals as a restriction of the integers, for example
<mellum>
No, it's not.
<mellum>
Why would that be useful anyway_
<salo>
well, if my variable is intended to be a natural number ...
<Submarine>
there are indeed no subrange types
<Submarine>
mellum, one could possibly desire types obtained by filtering a type by a decidable predicate
<mellum>
And what should happen if you write a-b? The ressult would be a different type? Or would you get an exception at run time? Both suck.
<Submarine>
with a runtime exception with bad assignments
<Submarine>
salo, you use assertions for that kind of stuff
<salo>
a-b<0 might yield NaN, perhaps.
<mellum>
salo: that would induce a large overhead, which is opposed to the goals of Ocaml
<salo>
fair enough.
<vincenz>
I think if ocaml had typeclasses like haskell it would be possible
<Submarine>
mellum, it incurs a large overhead unless you do static analysis to make it go away
<Submarine>
but interprocedural static analysis in a functional language...
<Submarine>
sounds hot stuff
<mellum>
Submarine: I don't think analysis would help a lot there. Eventually, there are variables that come from the environment and about which you know nothing
<Smerdyakov>
MLton does major interprocedural static analysis.
<Submarine>
mellum, you can usually draw significant information to eliminate such runtime checks
<Submarine>
for instance, if you have a variable that you specify in [0,n-1]
<Submarine>
and all assignments clearly verify this invariant
<Submarine>
then you can remove those runtime checks
<Submarine>
remember that this is *not* verification, you can still leave 15% of the checks and be considered "good"
xerox has joined #ocaml
<Nutssh>
Hi Submarine... I've been trying to catch you.
<Smerdyakov>
Try peanut butter under a cardboard box, with a stick set up to bring the box down over him when he reaches for the peanut butter.
<Submarine>
?
budjet has joined #ocaml
CosmicRay has joined #ocaml
patatof has quit []
budjet has quit [Remote closed the connection]
smimou has quit ["?"]
lodewijk has joined #ocaml
taras has joined #ocaml
<taras>
hi, i'm having some issues with ocaml multidimensional arrays
<taras>
and using references for indexes
<vincenz>
that's great, it'd be even greater if you mentioned what issuses
<taras>
hmm, gimme a second
<taras>
sorry
<vincenz>
?
<taras>
ok
<taras>
# let maxits=10;;
<taras>
val maxits : int = 10
<taras>
# let r = Array.create maxits (Array.create maxits (0.));;
<taras>
this seems to be a bad way to create a multidimensional array
<taras>
isn't it?
<Smerdyakov>
Do you understand what it does?
<taras>
it creates an array where all elements point to the same array :(
<Smerdyakov>
Yup. That's bad if it's not what you want.
<vincenz>
taras: basically you're creating an array with 10 entries that all point to the same row(column, depending on how you look at it)
<taras>
what's the proper way to do this?
<Smerdyakov>
taras, have you looked at the documentation on Array?
<Smerdyakov>
That would work, but I suggest reading further for a quicker way.
* vincenz
thinks that make_matrix is very limited
<Smerdyakov>
Right.
<vincenz>
it assumes that people only have 2-D matrices and not higher-dimensional ones
<taras>
yeah, i dislike these things that deal with sideeffects
<Smerdyakov>
vincenz, no. It quite clearly only deals with 2D matrices.
<taras>
they feel so odd after dealing with lists
<vincenz>
Smerdyakov: I know
<Smerdyakov>
vincenz, so it's not a problem for it to assume that!
<vincenz>
Smerdyakov: It assumes that people only want to create 2D matrices, not other dimensions, they could've made it more general by allowing teh user to pass a list of dimenstiions
<vincenz>
aka, the library is shortsighed
<Smerdyakov>
No, it _doesn't_ assume that.
<Smerdyakov>
It is only a function to be used in particular cases. It does not restrict what you can do with other methods.
<vincenz>
I know
<vincenz>
but why create something specific for2D instead of making a more general function for any d
<Smerdyakov>
And try thinking about your last suggestion.
<Smerdyakov>
What type would you give to such a function?
<vincenz>
hmm
<vincenz>
touche
<taras>
doesnt Array.init do the general thing anyway?
<Smerdyakov>
taras, it doesn't do "the general thing" of making multi-dimensional matrices with constant-sized code.
<taras>
ah
<taras>
btw, i keep running into the same take
<taras>
task
<taras>
what's the proper way of generating arbitrary sequences?
<taras>
say sometimes i need 1,2,3,4
<taras>
other times i need 1,3,5
<Smerdyakov>
How can there be a general way of generating "arbitrary" sequences?
<taras>
is there some sort of a higher order routine that should be used?
<vincenz>
depends on the complexity of the sequence
<taras>
simple ones
<Nutssh>
Submarine, I found that changing the heap grow increment from 28kb to 512kb was worth ~15%.
<vincenz>
if the sequence is linear a simple function of int->int will do
<taras>
hmm?
<taras>
maybe i wasn't clear enough...i noticed that i often need to create simple finite sequences, for example [1;1;1;1] or [1;2;3], etc
<taras>
how would an int->int help here?
<Smerdyakov>
See the List.tabulate function of the SML Basis.
<Nutssh>
What do you mean 'create'?
<taras>
man
<taras>
i missed the tabulate function
<taras>
i looked for it 3 or 4 different times in the list module
<taras>
i'm blind
<taras>
err
<Smerdyakov>
taras, it's in SML, not OCaml.
<taras>
sml basis
<taras>
yeah i used that in sml
<Smerdyakov>
taras, it should be easy for you to write your own version.
<taras>
i do write my own version
<vincenz>
well then generalize it
<Smerdyakov>
taras, what has motivated your choice of OCaml over SML?
<vincenz>
pass it a closure that keeps state
<taras>
Smerdyakov: it's a bit more liberal
<taras>
it provides more imperative stuff
<taras>
which is good when i cut &paste pseudocode
<Smerdyakov>
taras, not much more....
<taras>
Smerdyakov: hmm?
<Smerdyakov>
taras, OCaml does not provide much more "imperative stuff" than SML does.