comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: renaming Interfaces.Java.Ada_To_Java_String to the + operator
Date: 1998/01/11
Date: 1998-01-11T00:00:00+00:00	[thread overview]
Message-ID: <dewar.884531217@merv> (raw)
In-Reply-To: 871zyej2sg.fsf@ix.netcom.com


Chris said

<<In the Intermetrics X11 and Motif bindings there is a generic &
operator which is used to approximate the variable argument list C
functions in the original interface, allowing you to write stuff like
this :
>>

The other way of handling variable length lists is to use an
aggregate

   subprogname ((arg1, arg2, arg3, arg4, ....));

that is definitely neater than &. Furthermore, if you use the & approach
you have to be very careful not to introduce quadratic processing (which
is often quite tricky to do, if the target is really an array (*))

If you need heterogenous typing, then you define an appropriate union
type, and convert to it:

   subprogname ((+arg1, +arg2, +arg3, +arg4, ....))

which still retains linear processing time. If Chris' example is anywhere
near realistic (where many operands were joined with &), then I think the
use of & was probably not such a good choice as using aggregates.

(*) the problem of aggregated operators, concatenation on strings is
a canonical example, is an interesting one. No language in common use
tries to address the issue of converting

      A & B & C & D ...

into what is wanted, which is

      Concat ((A,B,C,D ...))

I can certainly imagine a pragma that would have this effect:

      pragma Collect_Operation (Operation => name, Subprogram => name);

where the parameters designate the dyadic operator to be treated,
which needs to have the profile (typ X typ => typ), and the
corresponding subprogram, which needs to have the profile
(row-of-typ => typ).

To use this for the builtin concatenation (many compilers special case this,
we just added this kind of special casing to GNAT), you also need to deal
with rowing of elements, i.e. if the operand typ is itself row-of-component,
then you allow components in the list with automatic rowing operations.


P.S. the above uses ALgol-68 notation and terminology, which is highly
convenient in a case like this:

row-of-x is a type that is a single dimension array whose component
type is x

rowing is the coercion that takes type x to type row-of-x





  reply	other threads:[~1998-01-11  0:00 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-11  0:00 renaming Interfaces.Java.Ada_To_Java_String to the + operator Terry J. Westley
1998-01-10  0:00 ` Robert Dewar
1998-01-10  0:00   ` Matthew Heaney
1998-01-13  0:00     ` Tom Moran
1998-01-13  0:00       ` Robert Dewar
1998-01-13  0:00       ` Stephen Leake
1998-01-13  0:00         ` Nick Roberts
1998-01-13  0:00       ` Stephen Leake
     [not found]       ` <En3Cxz.7HD@world.std.com>
1998-01-20  0:00         ` Robert Dewar
1998-01-21  0:00           ` Stephen Leake
1998-01-22  0:00           ` Robert Dewar
1998-01-22  0:00             ` Anonymous
     [not found]               ` <dewar.885498969@merv>
1998-01-23  0:00                 ` Geert Bosch
1998-01-23  0:00                 ` Tom Moran
1998-01-23  0:00             ` Anonymous
1998-01-24  0:00             ` Tucker Taft
1998-01-11  0:00   ` Chris Morgan
1998-01-11  0:00     ` Robert Dewar [this message]
1998-01-11  0:00       ` Chris Morgan
1998-01-11  0:00         ` Robert Dewar
1998-01-11  0:00           ` Chris Morgan
1998-01-11  0:00             ` Robert Dewar
1998-01-11  0:00 ` Nick Roberts
1998-01-11  0:00   ` Robert Dewar
1998-01-14  0:00     ` Anonymous
1998-01-14  0:00       ` Robert Dewar
1998-01-11  0:00   ` Brian Rogoff
1998-01-13  0:00     ` Terry J. Westley
1998-01-14  0:00       ` Robert Dewar
1998-01-15  0:00         ` Nick Roberts
1998-01-15  0:00           ` Robert Dewar
1998-01-16  0:00           ` Michael F Brenner
1998-01-16  0:00             ` Nick Roberts
1998-01-16  0:00               ` Robert Dewar
1998-01-17  0:00                 ` miniscences Nick Roberts
1998-01-17  0:00                   ` miniscences Robert Dewar
1998-01-19  0:00                 ` renaming Interfaces.Java.Ada_To_Java_String to the + operator Anonymous
1998-01-25  0:00                   ` Matthew Heaney
1998-01-16  0:00             ` Robert Dewar
1998-01-12  0:00 ` Tucker Taft
replies disabled

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