[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Miles Egan <miles@c...> |
| Subject: | Re: [Caml-list] a reckless proposal |
On Wed, Jul 25, 2001 at 10:30:09AM +0100, Dave Berry wrote:
> 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.
I suppose this is also similar to CLOS generics, right? I suppose this would be
more consistent but perhaps even more confusing to people who've been writing
ClassA.field and ClassB.field since the first day of their first Java class.
> 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.
Ocaml could observe this protocol as well. This is valid code:
class a =
object
val x = 1
method x = x
end
let _ = new a in
a#x
So a "macro" like attr_r could transform:
class a =
object
attr_r x = 1
end
into the above class definition.
Of course, you won't be able to assign to x in the way you'd expect:
let _ = new a in
a#x = 2
Won't work.
--
miles
"We in the past evade X, where X is something which we believe to be a
lion, through the act of running." - swiftrain@geocities.com
-------------------
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