English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
RE: [Caml-list] a reckless proposal
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-07-25 (09:33)
From: Dave Berry <Dave@k...>
Subject: RE: [Caml-list] a reckless proposal
> From: Miles Egan [mailto:miles@caddr.com]
> Sent: 24 July 2001 19:08
> Records are confusing because they resemble C
> structs and are used in similar ways, but are really quite 
> different.  Objects are confusing because their use is mildly
> discouraged and because their functionality significantly
> overlaps that of the module system.
> The most frustrating feature of records, of course, is that 
> each record field name must be globally unique.  Objects seem
> to provide more struct-like semantics, i.e. field names need
> only be unique within their class definition.

So perhaps Ocaml should adopt the approach used in Dylan and Moby,
where field names in class definitions have module scope.  Then
records and objects would have similar scoping rules, instead of
the current clash, and the distinction between modules and objects
would be clearer.

> For example, if object
> fields were directly accessible by default, one could use:
> class point =
>   object
>     val x = 0
>     val y = 0
>   end
> and access p.x and p.y directly, 

But if you then replace the field with an accessor method, you
have to edit all uses of that field.  It's a common recommendation
that OO languages should only access field by accessor methods (or
at least use the same syntax as accessor methods).  As you point
out, Ruby does it this way.  Dylan and Eiffel are other examples.

Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr