comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Hughes <eric.eh9@gmail.com>
Subject: Re: User-defined type attributes
Date: Thu, 13 Mar 2008 11:32:23 -0700 (PDT)
Date: 2008-03-13T11:32:23-07:00	[thread overview]
Message-ID: <30f629fd-69d3-4d40-995f-9933f52b8dad@s37g2000prg.googlegroups.com> (raw)
In-Reply-To: p0joauyj6p7$.z2nuhn0t1c78.dlg@40tude.net

On Mar 12, 3:23 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> Attributes in Ada aren't necessarily static, even type's attributes aren't.
> To me static functions is an independent, yet important issue.

Most attributes are completely static.  The ones that aren't (like
T'Callable, E'Caller) seem all to be of a kind that (1) statically
return a function (2) whose first parameter is the type of the object,
and then (3) apply it to that object.  Given that this is at least in
the spirit of a preelaborable attribute, there's the possibility of
treating these cases as syntactic shorthand: Obj'Attr for
Obj'Attr( Obj ), or alternately for Obj.Obj'Attr.  I did a brief scan
of ARM05/Annex-K just now, and this applies to all the cases I found
(which were all tasking or type attributes).

So I'll modify my idea to deal with historical syntax:
1) The definition of an attribute function has a static expression.
2) The syntax for invoking an attribute may imply a dynamic function
call.

Such implicit calls generate a syntax ambiguity between "attribute
procedure Op( X : T )" and "attribute procedure Op( X : T ; Y : T )"
when invoking with only positional parameters.  What would
Obj'Op( Obj ) mean?  I assume this can be adequately addressed.

> In my view attributes should be primitive operations. I would handle them
> similarly to prefix notation. I.e. X(Y,Z), Y.X(Z), Y'X(Z) considered
> equivalent.

The whole point of user attributes is to gain cleaner syntax for
referring to the environment of a type or object, that which is
available at pre-elaboration time, and supports generic programming
better.  Without such a syntax there are lots more formal parameters
that need to be forwarded around.

Just making attributes run-time functions eliminates a useful
distinction.  Functions on a type are part of the tradition algebraic
specification of a type.  Attributes on a type are part of the
language environment inside of which a type specification is
expressed.  These are very different.

> When applied to types, that should be treated just as a
> parameter of the type Tag.

That seems like the right way to treat the first parameter of an
implicit function call for an attribute on a type.

Eric



  reply	other threads:[~2008-03-13 18:32 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12 18:58 User-defined type attributes Eric Hughes
2008-03-12 21:23 ` Dmitry A. Kazakov
2008-03-13 18:32   ` Eric Hughes [this message]
2008-03-13 19:58     ` Dmitry A. Kazakov
2008-03-14  1:46       ` Randy Brukardt
2008-03-14  1:46       ` Randy Brukardt
2008-03-14  1:46       ` Randy Brukardt
2008-03-14  9:00         ` Dmitry A. Kazakov
2008-03-14 14:36           ` User-defined type attributes (replacing genericity) Georg Bauhaus
2008-03-15  3:04           ` User-defined type attributes Randy Brukardt
2008-03-15  9:33             ` Dmitry A. Kazakov
2008-03-14 14:31         ` User-defined type attributes (replacing genericity) Georg Bauhaus
2008-03-14 14:48           ` Dmitry A. Kazakov
2008-03-14 17:51             ` Eric Hughes
2008-03-14 18:58               ` Dmitry A. Kazakov
2008-03-14 20:19                 ` Eric Hughes
2008-03-15  4:01               ` Randy Brukardt
2008-03-14 16:58           ` Georg Bauhaus
2008-03-14 18:39             ` Dmitry A. Kazakov
2008-03-15  9:39               ` Dmitry A. Kazakov
2008-03-14  3:55       ` User-defined type attributes Eric Hughes
2008-03-14  9:01         ` Dmitry A. Kazakov
2008-03-14 18:04           ` Eric Hughes
2008-03-14  1:46 ` Randy Brukardt
2008-03-14  4:41   ` Eric Hughes
2008-03-15  3:20     ` Randy Brukardt
2008-03-17  4:38       ` Eric Hughes
2008-03-17 21:03         ` Randy Brukardt
2008-03-17 21:58           ` Eric Hughes
replies disabled

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