<ktne>
the main problem is that ocaml is a rather non-standard language so you really need to read a lot more to understand it, especially about type inference and such
ramkrsna has joined #ocaml
<ktne>
and unfortunatelly most tutorials are rather short
luca83 has joined #ocaml
<dark_light>
ktne, i agree
<ktne>
this oreilly books is quite good it seems
<dark_light>
i never understand the difference of 'a and '_a .. '_a is a "polymorphic type for mutable variables"? odd
<ktne>
well _a is different from a
<ktne>
the main different is that while 'a acts as a template '_a seems to be more like: wait for first use
<ktne>
at this this is what i understood
<dark_light>
Hmmmmmmmm..
<dark_light>
wait for first use?
<ktne>
'a works with any type (well mostly) so the function is polymorphic
<ktne>
while with '_a it works only with the first used type
<dark_light>
Hmmm..
<ktne>
so first time you use it becomes "unpolymorphic"
<dark_light>
# let e = ref None;; , val e : '_a option ref = {contents = None} , # e := Some 1;; , # e;; , - : int option ref = {contents = Some 1}
<dark_light>
odd
<dark_light>
ktne, there are a type that 'a doesn't match?
<ktne>
i don't know any
<ktne>
so probably it matches all, but i'm just learning ocaml so i can't give a definitive answer :)
<dark_light>
i think it matches all, well, it makes sense on my mind..
<luca83>
ktne: I think it matches all, but I'm learning OCaml too :)
<ktne>
luca83 :)
<ktne>
yes and it seems that '_a matches only the type that is used for the first time after definition
<dark_light>
i still don't understand how Printf.printf is built..
<luca83>
for sure, 'a matches any type for which polymorphic functions make sense
<ktne>
yes look at this example from the book:
<luca83>
ktne: it's nice to see many other beginners!
<ktne>
# let identity x = x;;
<ktne>
val identity : 'a -> 'a = <fun>
<ktne>
# let identity' = identity identity;;
<ktne>
val identity' : '_a -> '_a = <fun>
<ktne>
the first identity function is polymorphic: 'a -> 'a
<ktne>
but the identity' (identity composed with identity) is '_a -> '_a
<ktne>
# identity';;
<ktne>
- : '_a -> '_a = <fun>
<ktne>
so the type of identity' after definition is that
<ktne>
BUT
<luca83>
BUT, why?
<ktne>
# identity' 1;;
<ktne>
- : int = 1
<ktne>
now
<luca83>
why is'nt it polymorphic?
<ktne>
# identity';;
<ktne>
- : int -> int = <fun>
<ktne>
if you look you see that the type of identity' has changed!
<ktne>
from '_a -> '_a to int -> int after the first use of identity' (as in identity' 1;;)
<ktne>
now if we restart and dedefine
<ktne>
*redefine
<luca83>
may I had understood... now... I don't know ;)
<ktne>
# let identity' = identity identity;;
<ktne>
val identity' : '_a -> '_a = <fun>
<ktne>
so we redefined
<ktne>
# identity' "hello";;
<ktne>
- : string = "hello"
<luca83>
dark_light, ktne: we'll learn together ;) eheh
<ktne>
this returns "hello" as expected
<ktne>
BUT
<luca83>
ah ok!
<ktne>
the type of identity' has changed
<ktne>
# identity';;
<ktne>
- : string -> string = <fun>
<ktne>
so now it's string -> string
<luca83>
it depends from the particular nature of this function...
<ktne>
so in other words the type '_a -> '_a changes to the one that is used first time
<luca83>
depends BY
<dark_light>
ktne, it's odd, i don't understand why it behaves that way
<dark_light>
maybe i should read that pdf
<ktne>
well it says that it's a delayed type
<ktne>
'_a is not really polymorphic, it just says that it should take the first used type
<dark_light>
hmmm
<dark_light>
all '_a is resolved at compile time, right?
<ktne>
that's what i wonder
<ktne>
if it's at compile or runtime
<luca83>
BUT
<ktne>
wait to use an if
<dark_light>
if yes, i don't care if it's so odd
<luca83>
how the funcion "identity" is defined in the book?
<ktne>
how do you read something from console?
<ktne>
luca identity x = x;;
<luca83>
ktne: good, now it make sense for me, I think
<ktne>
dark_light test: read from console, if something then identity' 1 else identity "hello"
<ktne>
so if after this you get either int -> int or string->string depending on what you have read from console then it's at runtime
<luca83>
# let identity x = x;;
<luca83>
val identity : 'a -> 'a = <fun>
<ktne>
yes that makes sense
<ktne>
but let identity' = identity identity;; '_a -> '_a
<ktne>
i wonder why
<ktne>
because "identity identity" = identity(identity(x)) so "identity identity" should be 'a -> 'a too
<luca83>
the ocaml toplevel is too smart for me! :)
<ktne>
luca83 :)
<luca83>
(btw, I use it with rlwrap, so I have the command history... this is very important ;))
<dark_light>
if (read_int()) = 1 then ident' 1 else ident "ola";;
<dark_light>
This expression has type string but is here used with type int
<dark_light>
if (read_int()) = 1 then ident' 1 else ident' "ola";; isn't accepted too
<ktne>
well you have to reinit identity
<luca83>
obviously
<ktne>
oh
<ktne>
if .. then .. else must return the same type for both branches
<luca83>
like the functional if structure in perl etc.
<ktne>
well it makes sense because otherwise you would have a function with 2 output types
<luca83>
which would be unsafe...
<luca83>
oh I came back to study my data mining stuff... always here ;)
Schmurtz has joined #ocaml
<pango_>
ktne: weak type variables is a difficult topic (and I won't pretend to fully understand it either ;) )
<ktne>
pango_ :)
<ktne>
what i would like to know is how exactly this translates to lower level, such C or asm, if i would know how it's compiled then i guess that i would understand it :)
<pango_>
ktne: it's handled before compilation
<pango_>
ktne: try to put your identity and identity' functions in a module and compile it...
<pango_>
I think you only see weak variable types because you're using the toplevel, but I could be wrong on that point
<luca83>
pango_: neither I understand, this should be asked on the ml
<pango_>
another difficulty, is that there's no known algorithm to determine when it's safe to keep values polymorphic; only conservative approximations
<luca83>
pango_: 'cause: what happens if I compile a program in what i use different types for the same weak type?
<pango_>
luca83: it won't compile
<luca83>
pango_: it won't compile, if it's handled before compilation
<luca83>
but would the compiler detect that?
<ktne>
so a weak type is like a forward type specification? like forward declarations?
<ktne>
(forward in pascal, prototype in C)
<pango_>
... and compiler gets "better approximations" with time, so some examples given in the oreilly book for example, to not bring weak type variables anymore
<pango_>
luca83: yes, try compiling identity and identity' in a module. Alone, or with expressions using them...
<luca83>
pango_: I will try
<flux__>
ktne, btw, let identity' a = (identity identity) a works as expected
<flux__>
the issue is with partial applications, that won't in certain cicrcumtances be polymorphic
<flux__>
I think that may just be an optimization of some sort, as the compiler could easily rewrite partial function definitions into complete ones
<dark_light>
how can i load a module.ml in toplevel mantaining the escope of module? #use "some.ml" loads the file in global escope..
<pango_>
load it, then open it
<dark_light>
with #load? #load accepts only .cma files
<dark_light>
... or with use?
<pango_>
mmmh yes. I never use #use :)
<dark_light>
so i have to compile? in toplevel...?
<pango_>
#use just reads and interprets a file as if it was typed on keyboard
<pango_>
no modules, no namespaces
<pango_>
(I misread your question too, open will just do the opposite of what you asked for)
<pango_>
so, compile to bytecode, and load the module
<dark_light>
there should be a #compile-and-load "file.ml" then..
<dark_light>
btw, i would be happy if i could type let a = "file.ml";; and then #use a .. and, btw, i would be happy if i could use the <- and -> without deleting the line i am typing..
<dark_light>
(a historic like the bash would be very useful too)
<dark_light>
hm
<pango_>
that's it
<pango_>
thinking of it, you could use #use to load definitions in a module... By adding explicitly "module File = struct" at the beginning of the file and "end" at its end
<pango_>
but that's clunky ;)
<pango_>
static binding makes the OCaml toplevel much less nice than, say, a lisp toplevel; So I think most people use OCaml as a compiler, and just start the toplevel to load compiled modules, call functions or test code snippets
<pango_>
# let hello () = print_endline "Hello world!" ;;
<pango_>
# let greeting () = hello () ;;
<pango_>
# let hello () = print_endline "Hello dark_light!" ;;
<pango_>
# greeting () ;;
<pango_>
Hello world!
<dark_light>
pango_, Hmmmm
<dark_light>
i have to redefine things many times in ocaml's toplevel
<dark_light>
but it's nice anyway..
ninniuz has joined #ocaml
ninniuz has left #ocaml []
<pango_>
what about running the toplevel from within emacs then ? that will make re-submitting definitions much easier than thru copy&paste
<dark_light>
i have never used emacs before
<dark_light>
i edit the source code with gedit..:)
<pango_>
I learned to use emacs at uni, it's a great tool (even if I'm sure I'm only using 10% of its features ;) )
<flux__>
10% more likely 1%, methinks :-)
<flux__>
s/%/%?/
<pango_>
depends whether its features are bounded anyway :) Since it's programmable
<flux__>
I suppose one could think what is the code-coverage of emacs after one year of using it..
<pango_>
eheh time for profiling ;)
<pango_>
then remove all the unused code :)
dylan has left #ocaml []
<pango_>
so long, M-x psychoanalyse-pinhead ! ;)
Schmurtz has quit ["L'énergie semble manquer : dodo !"]
batdog is now known as batdog|gone
batdog|gone is now known as batdog
<luca83>
I like so much Emacs even if it so... XXL!
<luca83>
(Bettini campione del mondo!)
<pango_>
ever tried eclipse ? ;)
<nattfodd>
eclipse doesn't exist
<luca83>
pango_: eclipse on debian is an elephant
Schmurtz has joined #ocaml
<luca83>
pango_: I will try to use Eclipse with this dual-core athlon64-based desktop ;)
<luca83>
pango_: but emacs21 has all I need
<nattfodd>
and all you don't need too
<luca83>
nattfodd: yep!
<nattfodd>
as they say, emacs is a full os, all it lacks is a decent text editor
<luca83>
yes
<luca83>
well maybe it's not agile like e.g. vim, but for many programmers I think it's the best choice
* luca83
loves tuareg too
<luca83>
nattfodd: however you can use it with vim-el :-P
<nattfodd>
what's that?
<nattfodd>
anyway, omlet is more than enough for me
<jeremy_c>
I don't know why you guys say Emacs lacks a decent editor. That doesn't make sense to me.
<jeremy_c>
Eclipse does have a decent editor?!?
<nattfodd>
jeremy_c: no
<nattfodd>
but vim does
<jeremy_c>
nattfodd: navigation around your source file in vim is great, I wish other editors had such features. 3yy, 5wd, f", dt', etc...
<nattfodd>
yes, and not only that
<jeremy_c>
nattfodd: I still stand that most programmers know so little about there editor. If they would just pick one and spend some time learning it, they would be 100x happier. Emacs and Vim are both very capable editors.
<nattfodd>
yup
<nattfodd>
but emacs is ugly :)
<jeremy_c>
Yes, vim is prettier.
<jeremy_c>
I'm a converted textmate user though, and it beats vim in appearance hands down :-P
<flux__>
hmm.. maybe someone should arrange an editor competition..
<flux__>
provide file and an editing task
<flux__>
and have vim/emacs/etc-users aacomplish it ;)
<flux__>
you could have speed, number of keypresses and accuracy as metrics
<nattfodd>
jeremy_c: vim is pretty because my terms are
<jeremy_c>
flux__: that's a good idea but I think you will find that task A, emacs is better, task B, vim is better, task C, textmate is better, so in the end, it'll prob not prove much.
<flux__>
jeremy_c, thus there should be a number of tasks
<jeremy_c>
nattfodd: I compiled and used 256 color xterm for a while, you can make some pretty console apps that way.
<flux__>
jeremy_c, but the results could be inspected like the computer language shootdown..
<jeremy_c>
flux__: go for it :-)
<jeremy_c>
flux__: it is a very good idea.
<flux__>
maybe at some computer party or student event..
<pango_>
editors contest will turn into an editors contests content for sure ;)
<pango_>
s/content/contest/
<flux__>
suddenly a module "editingspeedcontest.el" will appear to xemacs.. ;)
<jeremy_c>
it may very well make some very nice additions to handle the deficiencies in Vim, Emacs, Textmate, etc...
<jeremy_c>
and make life better for us all, no matter which editor you use.
<jeremy_c>
flux__: you could revolutionize the world! Think of it, you could be a hero!!!
<flux__>
\o/
Godeke has quit [Read error: 110 (Connection timed out)]
DRMacIve1 has joined #ocaml
duncanm_ has joined #ocaml
<duncanm_>
i'm thinking of learning OCaml, is the O'Reilly book the best one I've got?
<dark_light>
i have 'a list or 'a array and i want to make the "list or array or .." polymorphic itself.. i could call the entire type 'b, but that way i can't get the 'a
<ktne>
i mean C++-man's :)
<dark_light>
ktne, hmm, my problem was the following:
<dark_light>
ktne, class ['a, 'b] circle (c : 'a 'b) (r : 'a) =
<ktne>
hmm, what (c : 'a 'b)?
<dark_light>
i was trying to implement the center (c) as a type like.. 'a center, or 'a float_center
<dark_light>
and the radius as 'a
<pango_>
type 'a list_or_array = AList of 'a list | AnArray of 'a array ?
<dark_light>
but it's impossible with ocaml
<pango_>
dark_light: at least that way ;)
<dark_light>
pango_, right, but i can't make list_or_array_or_you_choose..
<ktne>
why can't you have a type like that?
<dark_light>
pango_, yeah.. that way is what i though is cleaner, but Smerdyakov said that it makes inference impossible (or more difficult..)
<dark_light>
ktne, seems to difficult the type inference system (i don't know why)
<pango_>
dark_light: maybe using polymorphic variants then
<ktne>
a type called type CircleCenter = Int_center | Float_center ?
<dark_light>
pango_, ok, i was never introduced to them:)
<dark_light>
ktne, hmmm, yes, but i don't wanted to limit only for int or float
<dark_light>
and i can have a center with 2-dimension, 3-dimension..
<dark_light>
(in that case i would have a sphere, but it is only a detail)
<ktne>
ok then declare a class Center and use inheritance to define those center types :)
<dark_light>
Hmmm.. it seems the way that C++ handle things
<ktne>
well it's the natural way to handle this
<dark_light>
but a totally generic approach would be.. well.. beautier
<dark_light>
i love the way ocaml treat polymorphism
pattern has quit [Read error: 110 (Connection timed out)]
<dark_light>
ktne, i was not trying to solve any problem
<dark_light>
only testing the limits of the language
pattern- is now known as pattern
shekmalhen has joined #ocaml
<ktne>
ok but i guess that inheritance is to be used here
<ktne>
it seems quite natural
<ktne>
you define a common Center interface that has various implementations
<dark_light>
ktne, Hmmm..
<ktne>
just normal OOP, you don't need polymorphism
<dark_light>
ah, i don't need, you are right
<dark_light>
but i would feel more happy if i had it
<dark_light>
that's the point ^^
<ktne>
i don't see how could you use polymorphism other than specifying those things manually
<ktne>
using that type variant, in which case you would have to know all types in advance
<dark_light>
well, maybe 'a 'b could be accepted by ocaml
<ktne>
when you don't know all types i guess that you should use inheritance so that you can define new classes that share the sameinterface
<dark_light>
so 'b is a center (that is a object) and 'a is a linear type that i use to represent lengths
<ktne>
yes
<dark_light>
ktne, this approach isn't very familiar for me
<ktne>
what approach?
<ktne>
OOP?
<dark_light>
creating a common class Center and then inherit it
<dark_light>
maybe that's because i am not very familiar with OOP..
<ktne>
think about this: create a class Center and inherit it from: CartesianCenter, PolarCenter, etc
<ktne>
i wonder if you can define a type that is an array of a given size
<ktne>
how can you do that?
<dark_light>
i can't
<ktne>
let's say define a type that is an array of 3 elements of type 'a
<dark_light>
i can define a tuple
<pango_>
ktne: primitive types aren't enough, you need modules (or classes ?) to define a new abstract type
<ktne>
i'm just thinking how could you define something like CarthesianCenter(2) being a Carthesian center in 2D and PolarCenter(2) being a polar center in 2D too
<ktne>
those as types i mean, how could you define them in a parametric way, like PolarCenter(2), PolarCenter(3), etc
<ktne>
hmm, i guess you don't need them
<ktne>
i guess what you need is PolarCenter(a,b,c)
<ktne>
that would automatically have the right type
<dark_light>
you can use a normal array, and a non-mutable variable that says the dimension of center
<dark_light>
well, a tuple would fit well, unless you have 20 or 30D
<dark_light>
ktne, the approach i was trying is more functional.. and letting the type system do the ugly job always makes me happy
<ktne>
but it will do the type system if you use classes
<ktne>
there is nothing wrong with classes :)
jprieur has joined #ocaml
<jprieur>
hi there
<jprieur>
is there a simple way to convert a char to a string? It seems there's no built-in function.
<dark_light>
string_of_char?..
<dark_light>
*checking
<pango_>
dark_light: it's in extlib
<jprieur>
it doesn't exist :/ I tried it
<pango_>
String.make 1
<jprieur>
huh?
<pango_>
or Printf.sprintf "%c"
<dark_light>
hmm.. yeah.. String.make 1 'char'
<jprieur>
where is the documentation on String.make?
<jprieur>
do you know why string_of_char is not provided?
<pango_>
# let string_of_char = String.make 1 ;;
<pango_>
val string_of_char : char -> string = <fun>
<pango_>
but not very efficient either
<dark_light>
efficient? i think it's more efficient than sprintf..
<jprieur>
sure
<ktne>
you can define: let string_of_char = String.make 1;;
<dark_light>
and i don't know how make it more efficient without hardcoding in C (ok, this is ugly..)
<pango_>
jprieur: because it's not efficient
<ktne>
won't the compiler optimize here? since there is a 1 as constant used
<pango_>
jprieur: people usually avoid creating 1 character strings when they can
<pango_>
dark_light: by avoiding it
<dark_light>
pango_, but if i want to add a character to a string, it's very convenient creating a one character string and then using the concatenator operator
<pango_>
ktne: the cost is mainly string allocation
<dark_light>
it may not be the fastest way, but it's very convenient..
<dark_light>
creating a new string and then setting the last character may be faster, but less concise
<pango_>
dark_light: it's better to use Buffers, then
<pango_>
dark_light: never said it wasn't convenient
<dark_light>
hmmmm..
<pango_>
in fact, if it's convenient but unefficient, it's a good reason not to put it in standard libs ;)
<dark_light>
the compiler isn't smart enough to, let's say, when i use string ^ (String.make 1 char) it do not create the string and turn the process into the faster way?
<dark_light>
i don't know how the otimization is done, but i think that this kind of otimization is possible, because the compiler have the code of String.make and the ^ operator..
<jprieur>
# open Str;;
<jprieur>
# regexp;;
<jprieur>
Reference to undefined global `Str'
<dark_light>
jprieur, #load "str.cma"
<pango_>
like ?
<dark_light>
jprieur, and when you compile, you must include str.cma as a lib, before the .ml file
<pango_>
the only problem you could have with Buffer is that it's not functional, because otherwise it's very easy to use, even for small things
smimou has quit [Read error: 110 (Connection timed out)]
<dark_light>
if i need only to append a char to string and then forget it (send to stdout, etc) the process of creating a buffer with that string, then appending a char, then returning the string, seems very complicated
<dark_light>
if since the beginning i have a buffer, i would have no problem, but for small things (that i don't know i will put a char) it generally isn't the case
<pango_>
that's what functions are for
<dark_light>
let f string char = let buffer = Buffer.create ((String.length string) + 1) in Buffer.add_string buffer string; Buffer.add_char buffer char; Buffer.contents buffer
<dark_light>
like this?
<dark_light>
but it seems to be slower than string ^ (String.make 1 char)
<dark_light>
maybe becase i the implementation of ^ and String.make is hidden for me..
<pango_>
that defeats the purpose of using a Buffer, however
<pango_>
if you don't keep it around, both Buffer.add_string and Buffer.contents involve a copy
<pango_>
so complexity would be exactly the same
<dark_light>
that was i meant by 'little things'..
<pango_>
no, you're right, that's two copies, so using such function would be worse that just using strings
<pango_>
For little things I'd use Printf.sprintf "%s%c", performance be damned ;)
<ulfdoz_>
ich brauche: still und with teeth.
<ulfdoz_>
ECHAN, sorry
^daemon has quit [Remote closed the connection]
sponge45 has joined #ocaml
smimou has joined #ocaml
smimou has quit [Remote closed the connection]
shekmalhen has quit ["Snakes on Crack!!"]
smimou has joined #ocaml
shawn_ has quit [Read error: 60 (Operation timed out)]
shawn_ has joined #ocaml
<dark_light>
there is any way to inherit a class and use a method of this class in the initializer?
<dark_light>
i think i am with a ciclic dependency problem
<dark_light>
:(
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
david_koontz has joined #ocaml
chessguy has joined #ocaml
<sponge45>
dark_light: yes you can, why? What doesn't work for you?
<dark_light>
sponge45, i never tried, because how i will reference the object?
<dark_light>
i will have a thing like.. inherit something something primitive#something as primitive
<sponge45>
class c = object (self) inherit c0 initializer self#the_method end
<dark_light>
but i can't reference primitive before i declare it, and i must declare it after the initializeer
<dark_light>
sponge45, but i can't do: inherit c0 thing#something as thing
<dark_light>
sponge45, for initializer, i meant.. the parameters of the father object
<sponge45>
it seems complicated, there is a probably an easier way...
<dark_light>
my design is broken
<Smerdyakov>
dark_light, why don't you use the module system instead?
<dark_light>
:(
<dark_light>
Smerdyakov, i don't know
<dark_light>
my problem is:
<dark_light>
i have a primitive class of "connection", that does the dns resolve, the basic read/write, the basic connect/disconnect
<dark_light>
i need it to create a derivate "irc connection" class
<Smerdyakov>
Should be easy to do with modules.
<dark_light>
Hm. let me continue. so i must have a hook on the connect method (object#connect), so i can execute a function when i connect
<dark_light>
i am setting this hook in object parameters
<dark_light>
but this hook will call object#send so i can't define it in object parameter
<dark_light>
Smerdyakov, how can i do this with modules?
<Smerdyakov>
module type CONNECTION = sig type connection; val connect : connect_info -> connection; val disconnect : connection -> unit; (* etc. *) end
<dark_light>
a module for represent a connection instead of a class?
<sponge45>
what you can do is define the hook before the object (can you do that?)
<dark_light>
Smerdyakov, but.. but.. but....
<sponge45>
like: class c = let f () = ... in object ... end
<dark_light>
sponge45, no, because the hook will use methods included in object
<dark_light>
sponge45, i can use a object#set_hook function
<Smerdyakov>
module SpecialConnection = struct type connection = {parent : Connection.connection; otherStuff : whatever}; let connect info = let c = Connection.connect info in doOtherStuff c; {parent = c; otherStuff = something} end
<dark_light>
but i am unsure if i can have a mutable function
<dark_light>
Smerdyakov, well, seems nice, but, but, but.. i have a working code that uses OOP :(
<Smerdyakov>
dark_light, too bad for you.
<dark_light>
Smerdyakov, sure. i will try one more time my approach, because i want this work now
<dark_light>
maybe i will change to module approach later
<dark_light>
i have no need for finish this quick, so i can try another approach and compare the results.. but i think i can stay with OOP a bit more
<Smerdyakov>
OOP is an inferior technique in general, so it's no clear why you view sticking with it as a desirable criterion.
<dark_light>
Smerdyakov, i want to try it
<dark_light>
generally oop isn't very familiar to me, and i want to learn it too
<sponge45>
maybe you shouldn't inherit from the parent class.
<sponge45>
just keep it as a separate field/method
<dark_light>
i like functional programming and modules, but my first try is with modules, and it begun to working very quickly (i am actually very impressed with this)
<sponge45>
let p = new parent_class in object method the_parent = p ... end
<dark_light>
Hmmmmmmmm.....
<sponge45>
of course you need to initialize your parent
<sponge45>
mmmm
<sponge45>
just think about it :-)
<dark_light>
but this don't help to initialize the parent with a method that is from this parent
<dark_light>
sponge45, i can overwrite parent's methods, right? i think it's simpler than let p = new ..
<dark_light>
ps: oops, 'but my first try is with objects'
<sponge45>
you can always have a val init = ref None
<sponge45>
that must initialized later
<dark_light>
can i initialize non-mutable variables?
<sponge45>
I mean val mutable init = None is the same as val init = ref None
<sponge45>
that's usually the last resort when you stuck with cyclic dependencies
<sponge45>
your question was?
<dark_light>
:)
<dark_light>
my question was: there is any way to inherit a class and use a method of this class in the parent parameters?
<dark_light>
like that example, inherit myclass parent#test as parent
<sponge45>
what does "as parent" mean?
<dark_light>
that i can refer the parent class as.. parent
<dark_light>
so i can do later: method old_method = newcode; parent#old_method
<dark_light>
and add something to an old method
Amorphous has quit [Read error: 104 (Connection reset by peer)]
<dark_light>
is there any easy way to match strings against regexes?
<dark_light>
so technically it isn't compatible with standard ocaml?
<sponge45>
camlp4 is part of ocaml
<dark_light>
Hmmmmm
<dark_light>
so it will compile in ocaml without many hacks?
<sponge45>
technically it's a library which is loaded by the preprocessor
<sponge45>
what kind of hacks do you expect?
<dark_light>
i can define this library in the command line of ocamlc?
<sponge45>
use ocamlfind
<dark_light>
hmm?
<dark_light>
ok, i have no ocamlfind
<sponge45>
it's the program which is used with Findlib
<sponge45>
So look for findlib
<sponge45>
basically it finds the libraries for you, and their dependencies
<sponge45>
with camlp4 preprocessing plus some runtime libraries, it's too complicated without findlib/ocamlfind
<dark_light>
hmmm
<dark_light>
on the page there are some command lines using ocamlopt
<dark_light>
there are support for toplevel and ocamlc too?
<sponge45>
yes
<sponge45>
BTW i am the author
<dark_light>
ahah nice :)
<dark_light>
seems fine, but if i have no ocamlfind here, so to compile my program generally i make a makefile, and if it uses ocamlfind, i will say "you need ocaml *and* ocamlfind"..
<sponge45>
install ocamlfind
<dark_light>
but ok..
<dark_light>
sponge45, installed
<dark_light>
but when redistributing it, i must say "to compile you will need ocamlfind too"
<sponge45>
yes, but it's a widely-used tool now
<sponge45>
i know, dependencies are not cool
<dark_light>
i could not use ocamlfind, but if it makes the compiling interface easier..
<sponge45>
So far I've been using OCamlMakefile
<dark_light>
i didn't know that ocamlmakefile
<sponge45>
you just have to set the PACKS variable (instead of LIBS)
<dark_light>
i use tiny handwritten makefile..
<dark_light>
i like those large makefiles with many ./configure options, but i do not figured how to make it..
<sponge45>
ocamlmakefile is big, but your makefile will be very small
<dark_light>
sponge45, the syntax seemed odd, i have always used regexp with a single string, like "^[a-z]".. but that ['0'-'4'] | ['5'-'7'] seemed just like a regular ocaml match
<dark_light>
there is any chance that this library becomes a part of ocaml
<dark_light>
?
<dark_light>
RE (digit+ as x : int) "/" (digit+ as y : int) -> x, y it's fine for me.. :)
<sponge45>
part of ocaml? It would be nice, but it doesn't seem like it's going to happen.
<dark_light>
i don't know how things change in ocaml
<sponge45>
note that the syntax extends the syntax of ocamllex regexps, so it's not totally weird.
<dark_light>
but the people here always says that ocaml is a language that is still evolving..
<dark_light>
ocamllex?
<sponge45>
the thing about ocaml is that they are a small group researchers that cannot afford to spend much time developing or maintaining fancy libraries.
<sponge45>
I mean the core ocaml development team, not the rest of us :-)
<sponge45>
ocamllex is like lex, for ocaml :-)
<dark_light>
it's that Lexing module?
<dark_light>
i have no idea how lex works
<sponge45>
it's a preprocessor which is often used with ocamlyacc (another preprocessor), and yes it uses the Lexing module.
smimou has quit ["bli"]
<dark_light>
sponge45, i think ocaml core team should include at least partially the extlib..
<sponge45>
many people think that way
<dark_light>
in that way i think that the language should not be mantained by researches.. it should be mantained by community, like python, perl or php
<dark_light>
but i can be wrong in my assumptions :)
<Smerdyakov>
This is why OCaml doesn't have much of a future, in my opinion.
<sponge45>
this could change, but it will not change by itself
<dark_light>
SML is mantained by who?
<Smerdyakov>
MLton is maintained to the greatest extent by Stephen Weeks, who has no research institution affiliation. The MLton Subversion repo also allows commits by community members.
DRMacIver has joined #ocaml
shekmalhen has joined #ocaml
DRMacIve1 has quit [Read error: 110 (Connection timed out)]
<dark_light>
sponge45, can i use ["a-z."]+ ?
vadimtk has quit [Read error: 145 (Connection timed out)]
joshcryer has joined #ocaml
<dark_light>
ok, it seems i can..
CarMurder has joined #ocaml
CarMurder has left #ocaml []
<sponge45>
["a-z."] means either a or minus or z or dot. It's different from ['a'-'z' '.']
bzzbzz has joined #ocaml
<dark_light>
sponge45, hmm
Godeke has quit [niven.freenode.net irc.freenode.net]
Revision17 has quit [niven.freenode.net irc.freenode.net]