comp.lang.ada
 help / color / mirror / Atom feed
* Does Ada have macros ?
@ 1995-03-21 17:56 B Catlin
  1995-03-23  1:34 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: B Catlin @ 1995-03-21 17:56 UTC (permalink / raw)


I don't seem to remember Ada 83 having a macro capability, does Ada 95 ? 
If not, why not ?


        - Brian Catlin, Catlin & Associates Inc., Redondo Beach, CA (310)
798-8930
          VMS & Windows NT, Internals, Device Drivers & Communications



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Does Ada have macros ?
  1995-03-21 17:56 Does Ada have macros ? B Catlin
@ 1995-03-23  1:34 ` Robert Dewar
  1995-03-24 12:25 ` Mitch Gart
  1995-03-27  9:15 ` David Arno
  2 siblings, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1995-03-23  1:34 UTC (permalink / raw)


Actually, there was a Steelman requirement that the lanuage developed
NOT have a macro capability.

This was a well-thought-out requirement. Compile time macro facilities
tend to be dreadfully overused, resulting in horrible maintenance
problems, and furthermore, there is a tendency to use them to patch
up glaring omissions in the language. For example, C has no named
constants, a very bad omission, but #define can be used to patch
over this gap.

The better way to handle the equivalent of conditional compilation is
in most instances to isolate the system dependent parts and then put
them in separate units with multiple implementations.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Does Ada have macros ?
  1995-03-21 17:56 Does Ada have macros ? B Catlin
  1995-03-23  1:34 ` Robert Dewar
@ 1995-03-24 12:25 ` Mitch Gart
  1995-03-25 16:10   ` Henry Baker
  1995-03-27  9:15 ` David Arno
  2 siblings, 1 reply; 6+ messages in thread
From: Mitch Gart @ 1995-03-24 12:25 UTC (permalink / raw)


B Catlin (bcatlin@aol.com) wrote:
: I don't seem to remember Ada 83 having a macro capability, does Ada 95 ? 
: If not, why not ?

No macros, either in Ada 83 or Ada 95.  General text-substitution
macros like those in the C preprocessor are thought to be too 
unsafe.  For example, a macro can refer to a variable X and 
depending where the macro is expanded X may or may not be visible.
Ada programs are supposed to be readable and in many cases C
macros are one of the main culprits in producing unreadable C
programs.

In C macros can be used (and mis-used) in lots of ways but three legitimate
uses are for defining compile-time constants, types, and inline functions.
Ada has all three of these facilities.

	Mitch Gart



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Does Ada have macros ?
  1995-03-24 12:25 ` Mitch Gart
@ 1995-03-25 16:10   ` Henry Baker
  1995-03-27  2:50     ` B Catlin
  0 siblings, 1 reply; 6+ messages in thread
From: Henry Baker @ 1995-03-25 16:10 UTC (permalink / raw)


In article <D5y2J1.JAB@inmet.camb.inmet.com>, mg@asp.camb.inmet.com (Mitch
Gart) wrote:

> B Catlin (bcatlin@aol.com) wrote:
> : I don't seem to remember Ada 83 having a macro capability, does Ada 95 ? 
> : If not, why not ?
> 
> No macros, either in Ada 83 or Ada 95.  General text-substitution
> macros like those in the C preprocessor are thought to be too 
> unsafe.  For example, a macro can refer to a variable X and 
> depending where the macro is expanded X may or may not be visible.
> Ada programs are supposed to be readable and in many cases C
> macros are one of the main culprits in producing unreadable C
> programs.
> 
> In C macros can be used (and mis-used) in lots of ways but three legitimate
> uses are for defining compile-time constants, types, and inline functions.
> Ada has all three of these facilities.

Many implementations of 'generics' are essentially macro-expansions.

-- 
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Does Ada have macros ?
  1995-03-25 16:10   ` Henry Baker
@ 1995-03-27  2:50     ` B Catlin
  0 siblings, 0 replies; 6+ messages in thread
From: B Catlin @ 1995-03-27  2:50 UTC (permalink / raw)


 hbaker@netcom.com (Henry Baker) wrote:

>Many implementations of 'generics' are essentially macro-expansions.

Yes, but what about generating large complex tables?  I think that when
most peoply think about macros, they think of the C preprocessor, which in
my opinion really sucks.  I was thinking more along the lines of the macro
facility in the BLISS language.


        - Brian Catlin, Catlin & Associates Inc., Redondo Beach, CA (310)
798-8930
          VMS & Windows NT, Internals, Device Drivers & Communications



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Does Ada have macros ?
  1995-03-21 17:56 Does Ada have macros ? B Catlin
  1995-03-23  1:34 ` Robert Dewar
  1995-03-24 12:25 ` Mitch Gart
@ 1995-03-27  9:15 ` David Arno
  2 siblings, 0 replies; 6+ messages in thread
From: David Arno @ 1995-03-27  9:15 UTC (permalink / raw)


In article <3kn413$259@newsbf02.news.aol.com> bcatlin@aol.com "B Catlin" writes:

: I don't seem to remember Ada 83 having a macro capability, does Ada 95 ? 
: If not, why not ?
: 

I once came across a piece of C code that looked something like this (small
section only shown):

IF (JRXBBB NE JKLFUEL) THEN
   RRXFLOWR = 1.0;
ELSE
   RRXFLOWR = 2.0;
ENDIF;

etc. Basically, the person who wrote it had used FORTRAN for many years and
when required to use C, decided he hated it so created masses of macros that
allowed him to write C code with an (almost) FORTRAN syntax.

While this is an extreme case, such (mis)use of macros in languages such as
C is common and this is why I approve of languages like Ada that supply no
macro facility. What you see in a piece of Ada code is what you get (within
a debugger for example). This does not hold true for C or other macro languages.

-- 
David Arno



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1995-03-27  9:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-03-21 17:56 Does Ada have macros ? B Catlin
1995-03-23  1:34 ` Robert Dewar
1995-03-24 12:25 ` Mitch Gart
1995-03-25 16:10   ` Henry Baker
1995-03-27  2:50     ` B Catlin
1995-03-27  9:15 ` David Arno

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