List Info

Thread: "ocaml_beginners"::[] polymorphic methods (and I've read the same named section of the manual :-)




"ocaml_beginners"::[] polymorphic methods (and I've read the same named section of the manual :-)
user name
2006-01-01 13:40:16
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/
 


"ocaml_beginners"::[] Re: polymorphic methods (and I've read the same named section of the manual
user name
2006-07-28 12:25:09
> > 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)
> >
> > 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.
>

So do I think but not everybody does.

Actually I got aware of the (1) vs (2) problem while
observing some 
fact in oo programming under Matlab :
Matlab provides an oo system but the syntax to call methods 
is "method obj params" (which is unusual as
regards to java for 
instance).

An interesting phenomenon is that Matlab users who want to
do oo 
programming do not use the official Matlab oo, but a
"hand-made" oo 
that leads to a syntax of the form
"obj.method(params)".
After asking some users why they didn't use the official
oo, they all 
answered me that they prefer this syntax !

Hence my opinion on that topic 






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/
 



[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )