comp.lang.ada
 help / color / mirror / Atom feed
From: "Gavin Collings" <gcollings@sperry-sun.com>
Subject: Re: Visibility and access to "public" attributes
Date: 1997/09/02
Date: 1997-09-02T00:00:00+00:00	[thread overview]
Message-ID: <01bcb794$ec55a590$7e80400a@gavinspc> (raw)
In-Reply-To: 340BF0B7.BF7D3029@calfp.co.uk


Nick Leaton <nickle@calfp.co.uk> wrote in article
<340BF0B7.BF7D3029@calfp.co.uk>...
> Gavin Collings wrote:
> > 
> > Don Harrison <nospam@thanks.com.au> wrote in article
> > > What remains, of course, is the fact that the Eiffel mechanism is
simpler
> > > and more direct - objectively-speaking, that is.  :)
> > 
> > ... than Ada ... Agreed.  Would you care to contrast the Eiffel mechanism
> > (objectively, of course) with that specified for Delphi properties.  Here
I
> > have complete freedom to define within say class circle.
> > 
> > [snip radius property example]
> > 
> > Apart, perhaps, from the overhead of having to declare fRadius
separately,
> > this method looks certainly more flexible and probably in most
interesting
> > cases more direct than the Eiffel approach.
> > 
> 
> A bit obscure. Lets say you also have area as a readable atribute.
> Setting the area is possible, since we can derive the radius as a
> consequence. How does
> that work with Delphi.

I'm not entirely sure what you mean, but if your asking can you define an
Area property that defines side effects which act purely on the radius, the
answer is yes.  It works like this:

   property Area : Double read GetArea write SetArea

Then you can define the accessors - e.g. SetArea:

   procedure SetArea( newArea : Double )
   begin
      fRadius := sqrt( newArea / pi );
   end

Now I can write client code like:

   circle1.Area := 50.0;

You have complete control over which properties are read-only/read-write and
which directly access their respective fields (e.g. fRadius) or go via an
accessor method.

If you meant something else, you'd better elaborate a little.

-- 
Gavin Collings
gcollings@sperry-sun.com





  reply	other threads:[~1997-09-02  0:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-29  0:00 Visibility and access to "public" attributes card
1997-08-29  0:00 ` Patrick Doyle
     [not found]   ` <JSA.97Aug29190453@alexandria.organon.com>
1997-08-30  0:00     ` Patrick Doyle
1997-08-30  0:00       ` Jon S Anthony
1997-09-01  0:00         ` Patrick Doyle
1997-08-30  0:00 ` Darren New
1997-09-02  0:00 ` Don Harrison
1997-09-02  0:00   ` Don Harrison
1997-09-02  0:00     ` Jon S Anthony
1997-09-02  0:00     ` Gavin Collings
1997-09-02  0:00       ` Nick Leaton
1997-09-02  0:00         ` Gavin Collings [this message]
1997-09-02  0:00       ` Patrick Doyle
1997-09-03  0:00       ` Don Harrison
1997-09-05  0:00       ` Nick Leaton
1997-09-05  0:00         ` Patrick Doyle
     [not found]         ` <01bcba0e$418f7380$2001df0a@gavinspc>
1997-09-05  0:00           ` Nick Leaton
1997-09-02  0:00   ` Peter Horan
  -- strict thread matches above, loose matches on Subject: below --
1997-09-02  0:00 card
1997-08-29  0:00 card
1997-08-29  0:00 ` Ted Velkoff
1997-08-30  0:00 ` Darren New
1997-08-30  0:00 ` Patrick Doyle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox