caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Miles Egan <miles@caddr.com>
To: Dave Berry <Dave@kal.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] a reckless proposal
Date: Thu, 26 Jul 2001 08:35:24 -0700	[thread overview]
Message-ID: <20010726083524.B65526@caddr.com> (raw)
In-Reply-To: <8E31D6933A2FE64F8AE3CC1381EEDCE70B2AEA@NT.kal.com>; from Dave@kal.com on Wed, Jul 25, 2001 at 10:30:09AM +0100

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


  reply	other threads:[~2001-07-26 15:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-25  9:30 Dave Berry
2001-07-26 15:35 ` Miles Egan [this message]
2001-07-30 12:21   ` Bruce Hoult
  -- strict thread matches above, loose matches on Subject: below --
2001-07-24 18:08 Miles Egan
2001-07-24 19:44 ` Brian Rogoff
2001-07-24 21:02   ` Miles Egan
2001-07-25 15:15     ` Brian Rogoff
2001-07-26 15:27       ` Miles Egan
2001-07-26 15:47         ` Brian Rogoff
2001-07-26 16:01           ` Miles Egan
2001-07-26 21:19   ` John Max Skaller
2001-07-24 20:26 ` Sven
2001-07-24 20:51   ` Miles Egan
2001-07-25  8:30 ` FabienFleutot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010726083524.B65526@caddr.com \
    --to=miles@caddr.com \
    --cc=Dave@kal.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).