On Friday 28 July 2006 08:37, vincent.aravantinos wrote:
> I understand better now. In general the only usefull
thing about
> object is inheritance. The problem is that when OO
languages arrived,
> they came with things such as templates or spacenames,
so that people
> now make an amalgamate between all those notions.
>
> But something else comes into game to my eyes :
syntactically, you
> call an object using
> obj#method params (1)
> while if you implemented it as a package you would do
something like
> method obj params (2)
The alternatives to many OOP patterns provided by OCaml's
variant types etc.
are also more thoroughly statically checked.
> There is much "psychological" impact on the
programmer between the
> two syntax : in (1) we see that the method is
intimately bound to obj
> while in (2) obj is just a parameter among others.
> I really believe this encourages people to use objects
more than
> classical structures, even though they don't
necessarily need
> inheritance which is intrinsic to objects.
Maybe. But you would normally see:
Buffer.add buf string
which is just as obvious as "buf#add string",
IMHO.
> The problem there is that I have to make a compromise
between
> understandibility of my code and its performance (as
you seem to say
> that object is slower than others). It's a pity
because to my eyes
> one of the best features of ocaml is that I can make a
program easy
> to understand but very fast indeed.
Yes. There will always be a tradeoff between brevity and
performance but OCaml
does do a lot better in this respect compared to many other
languages (like
C++). For example, pattern matching is both succinct and
efficient.
Incidentally, the original problem you posted is about
polymorphic recursion,
AFAICT. I'll have a go at fixing it ASAP...
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scient
ists
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|