comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de>
Subject: spec/body/rep (Was: Compilation error (GNAT bug?))
Date: Wed, 21 May 2014 00:22:08 +0200
Date: 2014-05-21T00:22:09+02:00	[thread overview]
Message-ID: <537bd591$0$6621$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <lyoays70lj.fsf@pushface.org>

On 20/05/14 20:43, Simon Wright wrote:
> Victor Porton <porton@narod.ru> writes:
>
>> package My is
>>
>>     procedure C_Raptor_New_World
>>       with Import => True, Convention => C, External_Name => "raptor_new_world";
>>
>> end My;
>>
>> $ gnat compile -gnat2012 my.ads
>> gcc-4.6 -c -gnat2012 my.ads
>> my.ads:4:11: aspect identifier expected
>> gnatmake: "my.ads" compilation error
>>
>> Why it does not compile? Is it a GNAT bug?
>
> No, just an old version of GNAT. GCC 4.7 fails too; 4.8 is OK. GNAT GPL
> 2011 fails; 2012 is OK.

  procedure Foo (Arg : in out T)
    with
       Global => ...
       Pre => ...
      Post => ...
      Convention => ...
      External_Name => ...
      Linker_Options => ...
      Inline;

Some aspects, such as Linker_Options, are about things outside the
program. A Convention identifier less so, it addresses any client of
package My and insofar belongs in the public part with the declaration.
Then there are aspects of still other kinds, such as Pre/Post conditions
of contracts. They cannot very well exist without their declarative item,
just like pragmatic aspect Inline, although the latter may written
separately.

The pin board style list of aspects just lumps all of these different
kinds together after "with".

What if the "external aspects" went elsewhere? For example, in a
representation unit. (That's a name I remember). With rep units,
the source text proper becomes more portable, and more configurable
at the same time. There is no need to change aspects in the source
text when switching environments or when changing the configuration
(Linker_Options is one example). Just pick a suitable rep unit.
Declarations also become more readable, insofar as they'd focus on
just the logic, not link names and such.

Representation units can provide an Ada version of dependency
injection, even when injection happens at compile time.

In fact, GNAT already supports "outsourcing" certain aspects with the
help of project files. Do some of the other compilers do that, too?

Since aspects are a fairly new addition to the language, chances
are that representation units will not generate backwards compatibility
issues.

Would representation units help producing clear separation of concerns?



  reply	other threads:[~2014-05-20 22:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 18:32 Compilation error (GNAT bug?) Victor Porton
2014-05-20 18:43 ` Simon Wright
2014-05-20 22:22   ` Georg Bauhaus [this message]
2014-05-23 21:21     ` spec/body/rep (Was: Compilation error (GNAT bug?)) Randy Brukardt
2014-05-27  5:16       ` J-P. Rosen
2014-05-27  6:22         ` Niklas Holsti
2014-05-27  8:54           ` J-P. Rosen
2014-05-27  8:55           ` Dmitry A. Kazakov
2014-05-27 15:45             ` G.B.
2014-05-27 16:41               ` Dmitry A. Kazakov
2014-05-27 16:52                 ` G.B.
2014-05-27 17:03                   ` Dmitry A. Kazakov
2014-05-27 22:57               ` Randy Brukardt
replies disabled

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