comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: ANNOUNCE: Avatox 1.0 is now available
Date: Thu, 7 Sep 2006 21:40:23 -0500
Date: 2006-09-07T21:40:23-05:00	[thread overview]
Message-ID: <KfOdnRXjCaddSp3YnZ2dnUVZ_q6dnZ2d@megapath.net> (raw)
In-Reply-To: m2u03jquay.fsf@grendel.local

"Simon Wright" <simon@pushface.org> wrote in message
news:m2u03jquay.fsf@grendel.local...
> "Randy Brukardt" <randy@rrsoftware.com> writes:
>
> > It is reported that determining whether a type is limited takes 96
> > lines of Ada (ASIS) code - but this is a property that every Ada
> > compiler has a subprogram to calculate. It should be directly
> > available in ASIS.
>
> Via Traits, yes? (which struck me as more than a bit of a kludge when
> I grasped it). It takes me about 60 lines to process all the
> possible/appropriate traits (assuming that the ASIS tree is
> well-formed, so that if a declaration has an
> Asis.An_Abstract_Limited_Private_Trait it's appropriate to mark it
> abstract, limited and private).

Well, actually, ASIS really has two intersecting (but not equivalent)
domains: the syntax domain and the semantic domain. ASIS rules currently
allow stuff that does not appear in the program text (like inherited
subprograms) to not show up in the ASIS queries. That's fine if you're doing
a text transformation (although ASIS annoyingly allows such stuff to appear
in ASIS queries, which can make a pure text transformation harder), but
awful if you need to dig deeper. One nasty example is that the routine that
returns the type of an object is defined to return null if the type of the
object is classwide. So how do you find out anything about that type??
Another nasty case is the aforementioned inherited subprograms -- if you
call one, you can't get the declaration of the routine that was called. But
that is often the hardest part of Ada to figure out -- I sometimes have to
read compiler symbol dumps to figure out what is going on, and it's
something that ASIS should be handling.

So the current thinking (very preliminary, I point out) is that the current
ASIS spec will be used to represent the syntactic domain, and an entirely
new set of functions and types will represent the semantic domain. (Existing
semantic queries that use the syntactic domain types in current ASIS would
be marked as obsolete and most likely not upgraded to handle new Ada 2005
concepts). This way, if you want the type of an object, you can ask for it,
and then make appropriate queries on the type object (not necessarily
associated with some source code) to find out the properties. The properties
might be traits, or simply query functions (there has been a *lot* of
discussion of this, especially as some of the traits overlap in Ada 2005
where they did not in Ada 95, thus making program breakage inevitable).
There will be ways to move back and forth between the domains: for instance,
given a type object, you can get the source code that declared it. Given a
type declaration, you can get the associated type object. Etc.

(Note: I don't see an obvious way to flatten this extra information in XML.
It's not flat in Janus/Ada; there are a number of tables that collectvely
make up the compiler symboltable, and we only flatten each one in turn. But
I'm sure you clever guys will figure out a way.)

> I see that this isn't always quite obvious: I have
>
>     type Request is limited private;
>
> giving
>
>     <private_type_declaration limited="true" private="true">
>       <defining_identifier>Request</defining_identifier>
>       <private_type_definition limited="true" private="true">
>       </private_type_definition>
>     </private_type_declaration>
>
> which seems odd (I guess that the definition is of the anonymous type
> of which the declaration is the first named subtype?)

Anonymous types shouldn't appear in the syntactic domain, but ASIS 99 does
give that sort of flexibility to implementers. Not clear what the final
decision will be on that (especially at this early stage). I'd like the
syntax domain to only provide stuff that is actually in the source code; the
meaning of the program is in the semantic domain and would be covered by new
functions. That makes nothing much optional, and ASIS programs should be
easier to write.

The problem here really is that ASIS 99 is really only the syntactic domain.
 So if you have:

     type Foo is new Bar;

this type will *not* have the limited trait, even if Foo is a limited type.
ASIS 99 is generally talking about what appears in the source code only
(although there are exceptions). So if you want to know if Foo is limited,
you have to look at the declaration of Bar. That gets complex, and it's
silly since ASIS is supposed to be making what the compiler knows
accessible, and surely the compiler knows whether Foo is limited!

> > Moreover, virtually everything in ASIS is currently optional, which
> > makes writing ASIS programs that are portable very difficult. Plus,
> > the standard itself is poorly written, and it's organization is such
> > that it is arguable that ASIS users (not to mention implementers)
> > need a license from ISO. So we're going to be busy redoing the
> > entire standard.
>
> This sounds like good news.

I think so, too. It turns out that most of the ARG had never read the ASIS
standard in detail, and when they did, they were surprised to find that it
really didn't do what it set out to do: provide a window into the compiler's
information. Either it requires creating stuff that the compiler doesn't
have or need, or it doesn't provide a way to get to the information in a
sane way at all. Hopefully we can clear this up without starting over (which
is clearly not acceptable).

                         Randy.





  reply	other threads:[~2006-09-08  2:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-17  0:58 ANNOUNCE: Avatox 1.0 is now available Marc A. Criley
2006-08-17  2:10 ` Jeffrey Creem
2006-08-18  8:03 ` Pascal Obry
2006-08-18  8:04 ` Pascal Obry
2006-08-18  8:05 ` Pascal Obry
2006-08-21 20:59 ` Simon Wright
2006-08-24  0:41   ` Marc A. Criley
2006-08-24  6:03     ` Simon Wright
2006-08-25  1:15       ` Marc A. Criley
2006-09-06 23:29       ` Randy Brukardt
2006-09-07 20:46         ` Simon Wright
2006-09-08  2:40           ` Randy Brukardt [this message]
2006-09-08 13:40             ` Georg Bauhaus
2006-09-09  8:28               ` Manuel Collado
2006-09-09 12:21                 ` Simon Wright
2006-09-11  7:58                   ` Manuel Collado
2006-09-09 18:56                 ` Marc A. Criley
2006-09-11  8:10                   ` Manuel Collado
replies disabled

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