From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Properties
Date: Mon, 29 Nov 2010 17:54:51 +0100
Date: 2010-11-29T17:54:52+01:00 [thread overview]
Message-ID: <4cf3dadc$0$6883$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <3e9dfa01-6975-401d-999d-7cf87e926fb3@z9g2000yqz.googlegroups.com>
On 28.11.10 22:22, Shark8 wrote:
> It probably would
> have looked something like this:
>
> Type String_Data_Object( String_Data : Access String ) is
> Limited Tagged; --Forward declared.
>
> Type PS_String( Data_Object : Access String_Data_Object ) is
> New PostScript_Object with record
> Start, Stop : Positive; -- String'First/'Last equiv.
> The_String : Separate String;
> end record;
> For PS_String.The_String.Read Use
> Data_Object.String_Data.All( Start..Stop );
> For PS_String.The_String.Write Use
> Data_Object.String_Data.All( Start..Stop );
To the extend I have understood the approach,
you can do this with current Ada. Just make
The_String aware of its surroundings (not sure
I got the String_Data_Object involved as should):
type PS_String;
type PostScript_String (Referred : access PS_String;
Capacity : Positive) is
record
Data : String (1 .. Capacity);
end record;
type PS_String( Data_Object : access String_Data_Object;
Capacity : Positive) is limited
new PostScript_Object with record
Start, Stop : Positive; -- String'First/'Last equiv.
The_String : PostScript_String (PS_String'Access, Capacity);
end record;
Then you can define a user defined 'Write attribute
for PostScript_String that does use Start and Stop
from PS_String to select a range from the string's data:
procedure Write_PostScript_String
(Stream : access Ada.Streams.Root_Stream_Type'Class;
Object : PostScript_String)
is
Link : PS_String renames Object.Referred.all; -- the surroundings
begin
String'Write(Stream, Object.Data (Link.Start .. Link.Stop));
end Write_PostScript_String;
>> 2 - What if a property of an object needs to refer to two or more
>> of its components?
>>
>> Say, a property's public view perhaps being much better presented
>> as a Point rather than as forcing two Coordinate properties (even
>> though Coordinates may have been chosen for internal representation
>> in a record).
>
> That's kinda easy:
> -- for referring to multiple fields.
I think I meant the other way around, as in the Get_XY
example:
> Type Point is Record
> X, Y : Integer
> End Record;
>
> Type Point_3D is
> X, Y, Z : Integer;
> Parallel_Projected : Separate Point;
For Parallel_Projected'Read Use ???;
> end record;
Suppose clients of your private Point_3D should be able
to see a property whose computation (result is Point) involves
both components X and Y under the hood. Call it the Shadow
property, maybe.
More generally, I might have
type R is private;
function Spatial_Needs (Item : R) return Area_N;
private
type R is record
X1, X2, ..., Xm : Distance;
Y1, Y2, ..., Yn : Something;
...
end record;
Spatial_Needs is computed from X1, X2, X5, X12, and
Z3 to Z6. Will standardized properties help provide for this?
>> 3 - Is there anything in properties that helps with order of
>> component access? (Just an idea.)
>
> I'm not sure I know what you mean by this... do you mean the order as
> in how Ada automatically orders the internals of a record when piping
> them to a stream?
Something new, and probably not simple: the type's operations
can be called in a specific order only. For example, do not
call property p3 before both p1 and p2 have been set.
>> As an alternative, I'd suggest an option to remove definitions
>> of full views of types from the specs.
>
> Hm, I'm not sure I see what use that would be.
Somewhat like the pointer-to-implementation approach.
The full type definition is in the body of a package
(or in some representation part of a package which
is separate from both the spec and the body), for example.
Every read/write of one or more components is done through
some primitive operation. A user of the type has no idea
what the component parts of an object might be.
next prev parent reply other threads:[~2010-11-29 16:54 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-28 3:21 Properties Shark8
2010-11-28 8:15 ` Properties Dmitry A. Kazakov
2010-11-28 19:43 ` Properties Shark8
2010-11-29 8:34 ` Properties Dmitry A. Kazakov
2010-12-01 18:15 ` Properties Shark8
2010-11-28 12:37 ` Properties Georg Bauhaus
2010-11-28 21:22 ` Properties Shark8
2010-11-29 16:54 ` Georg Bauhaus [this message]
2010-12-01 19:52 ` Properties Martin Krischik
2010-12-01 23:24 ` Properties Georg Bauhaus
2010-12-05 16:15 ` (placepo) Properties Martin Krischik
2010-12-06 23:24 ` Shark8
2010-12-01 23:31 ` Properties Georg Bauhaus
2010-11-30 1:49 ` Properties Randy Brukardt
2010-11-30 16:58 ` Properties Charmed Snark
2010-11-30 17:22 ` Properties Dmitry A. Kazakov
2010-11-30 20:27 ` Properties Warren
2010-12-01 8:39 ` Properties Dmitry A. Kazakov
2010-12-01 15:21 ` Properties Warren
2010-12-01 15:59 ` Properties Dmitry A. Kazakov
2010-12-01 16:20 ` Properties Warren
2010-12-01 18:22 ` Properties Dmitry A. Kazakov
2010-12-01 19:36 ` Properties Shark8
2010-12-01 21:13 ` Properties Dmitry A. Kazakov
2010-12-01 21:35 ` Properties Maciej Sobczak
2010-12-01 21:45 ` Properties Dmitry A. Kazakov
2010-12-02 9:57 ` Properties Maciej Sobczak
2010-12-02 10:26 ` Properties Dmitry A. Kazakov
2010-12-02 15:25 ` Properties Maciej Sobczak
2010-12-02 15:46 ` Properties Dmitry A. Kazakov
2010-12-02 21:11 ` Properties Maciej Sobczak
2010-12-02 22:19 ` Properties Dmitry A. Kazakov
2010-12-03 4:43 ` Properties Randy Brukardt
2010-12-03 13:53 ` Properties Maciej Sobczak
2010-12-03 21:32 ` Properties Randy Brukardt
2010-12-04 22:13 ` Properties Maciej Sobczak
2010-12-06 23:30 ` Properties Shark8
2010-12-06 23:33 ` Properties Randy Brukardt
2010-12-04 17:43 ` Properties Simon Wright
2010-12-04 20:48 ` Properties Dmitry A. Kazakov
2010-12-04 22:27 ` Properties Simon Wright
2010-12-04 22:31 ` Properties Vinzent Hoefler
2010-12-03 4:24 ` Properties Randy Brukardt
2010-12-03 5:00 ` Properties Shark8
2010-12-03 21:10 ` Properties Randy Brukardt
2010-12-03 23:34 ` Properties Jeffrey Carter
2010-12-06 6:02 ` Properties Brad Moore
2010-12-06 23:25 ` Properties Shark8
2010-12-01 19:48 ` Properties Randy Brukardt
2010-12-01 21:10 ` Properties Warren
2010-12-02 0:03 ` Properties Shark8
2010-12-02 16:45 ` Properties Warren
2010-12-02 17:32 ` Properties Dmitry A. Kazakov
2010-12-02 20:45 ` Properties Warren
2010-12-02 21:17 ` Properties Adam Beneschan
2010-12-02 21:40 ` Properties Warren
2010-12-03 3:34 ` Properties Shark8
2010-12-03 8:16 ` Properties Thomas Løcke
2010-12-02 20:52 ` Properties Pascal Obry
2010-12-02 19:46 ` Properties Adam Beneschan
2010-12-02 20:38 ` Properties Warren
2010-12-02 21:39 ` Properties Jeffrey Carter
2010-12-02 21:55 ` Properties Warren
2010-12-03 9:33 ` Properties Anonymous
2010-12-03 3:47 ` Properties Shark8
2010-12-03 0:09 ` Properties Robert A Duff
2010-12-03 15:49 ` Properties Warren
2010-12-03 20:07 ` Properties Shark8
2010-12-06 21:01 ` Properties Warren
2010-12-06 23:22 ` Properties Shark8
2010-12-07 14:37 ` Properties Warren
2010-12-08 21:13 ` Properties Simon Wright
2010-12-09 1:21 ` Properties Shark8
2010-12-06 23:43 ` Properties Randy Brukardt
2010-12-07 0:56 ` Properties Jeffrey Carter
2010-12-07 11:23 ` Properties Maciej Sobczak
2010-12-07 11:51 ` Properties Georg Bauhaus
2010-12-07 15:35 ` Properties Maciej Sobczak
2010-12-07 17:02 ` Properties Georg Bauhaus
2010-12-07 14:39 ` Properties Warren
2010-12-03 15:40 ` Properties Warren
2010-12-03 19:56 ` Properties Shark8
2010-12-03 20:12 ` Properties Warren
2010-12-03 5:53 ` Properties Shark8
2010-12-03 9:05 ` Properties Dmitry A. Kazakov
2010-12-03 19:52 ` Properties Shark8
2010-12-03 21:14 ` Properties Randy Brukardt
2010-12-04 5:35 ` Properties Shark8
2010-12-04 14:23 ` Properties Peter C. Chapin
2010-12-04 18:53 ` Properties Shark8
2010-12-13 15:10 ` Properties Brian Drummond
2010-12-03 22:38 ` Properties Dmitry A. Kazakov
2010-12-04 3:12 ` Properties Shark8
2010-12-04 13:19 ` Properties Georg Bauhaus
-- strict thread matches above, loose matches on Subject: below --
2010-12-04 19:53 Properties Shark8
2010-12-04 23:27 ` Properties Thomas Løcke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox