comp.lang.ada
 help / color / mirror / Atom feed
* Re: ForTran-Ada + flamette + question
@ 1986-05-28 15:54 richw
  1986-05-30 12:46 ` Russ Holden
  0 siblings, 1 reply; 13+ messages in thread
From: richw @ 1986-05-28 15:54 UTC (permalink / raw)



The following includes a suggestion for solving your problem, along
with my own defense of the decision to omit procedure-pointers from Ada:

The first solution I can think of (and, I guess, the simplest?) would
be to define an enumeration type, where each enumeral (is that a
word?) corresponds to one of the functions you'd like to bind to a
key-sequence.  Then just write a procedure that takes such an enumeral
as an "in" parameter and then "case"s on that parameter to the
appropriate call.

Abstractly, this new function is similar to "eval" in Lisp.  Now, instead
of binding characters sequences to function-pointers (as in C), just bind
the character sequences to enumerals.

Other comments about why I think the ability to pass procedures around
was omitted from Ada: (note that these are just opinions -- I'm not
quoting one of the design documents for Ada or anything like that)

In a language like Lisp, you can actually create procedures AT RUN-TIME
since they're just lists (i.e. data).  However, in C and Ada this isn't
true.  In C, all procedures that you can point to at run-time are defined
at compile time.  I think this last fact is an important one to consider;
the above method of mapping enumerals to subprogram calls works for Ada.
It wouldn't work in Lisp because you can't list all of the subprograms
that will exist when you run the program BEFORE you run it (because you
can build Lisp procedures "on the fly"); thus, you can't define an
enumeration type since that type has a finite number of compile-time
enumerals.

Anyway, my point is that I think that one can do all that you can do in
C in Ada by using the above enumerals-to-subprogram mapping method; I'd
be interested if people can provide counter-examples (I realize that
you'd have to do more if the procedures you call take different numbers
of arguments, but then again, you'd have to be more fancy in C, too).

If so, then omitting the ability to pass procedures around in Ada saved
the language designers from adding more syntactic and semantic and
run-time constructs to the language to support this.  Considering
the fact that Ada is already big, I think this was a wise decision --
especially since, with a minimal amount of work, you CAN do what you
want (using the enumeral-to-subprogram method).

Think about it -- strict type-checking becomes much more messy...
It is possible to add this to your language (e.g. CLU), but I personally
don't think it's worth complicating your language.  Even though C lets
you do it, C BY NO MEANS does type-checking of calls to procedures which
were passed in as arguments (it doesn't even check that the number of
arguments is correct).  Yes, C is an "unsafe" language...

Comments?  Remember, these are casual remarks and opinions -- please
think before you flame  :-)

Rich

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: ForTran-Ada + flamette + questi
@ 1986-06-03 19:11 gore
  0 siblings, 0 replies; 13+ messages in thread
From: gore @ 1986-06-03 19:11 UTC (permalink / raw)



>[ Discussion about lack of pointers to procedures in Ada ]
>
>You've gotta draw the line somewhere.  I'm continually amazed how
>people complain that Ada has either too much or not enough because
>it's left out their favorite feature from language X.  Considering the
>design goals for Ada, I think they did a good (not perfect) job of
>designing a language with which you can write both efficient and
>abstract, safe programs.

Personally, my complaint is more about the incomplete orthogonality of Ada 
than about lack of specific features.  If task types (and hence pointers to
tasks) are allowed, why not allow procedure types, package types, entry types?
We should not automatically assume that addition of these automatically means
making the language bigger.  For example, if there was a way to maintain
structures of entries, there would be no need for "families of entries".

Another example:  If only 'in' parameters are allowed in functions, why allow
access to external variables from inside a function?

Jacob Gore
Northwestern Univ
Comp Sci Research Lab
ihnp4!nucsrl!gore

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

end of thread, other threads:[~1986-08-07 13:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1986-05-28 15:54 ForTran-Ada + flamette + question richw
1986-05-30 12:46 ` Russ Holden
1986-06-20 15:36   ` ForTran-Ada + flamette + questi richw
1986-06-22  3:00     ` Russ Holden
1986-06-22  7:49     ` Enumerated "procedural" parameters Alastair Milne
1986-07-03  7:03       ` Dick Dunn
1986-07-10 22:26     ` ForTran-Ada + flamette + questi friesen
1986-07-11 15:38       ` ForTran-Ada ... (really function pointers) markb
1986-07-14 17:01   ` ForTran-Ada + flamette + questi richw
1986-07-18 21:59     ` vilot
1986-07-22 12:59   ` stt
1986-08-07 13:26     ` Christopher Reedy
  -- strict thread matches above, loose matches on Subject: below --
1986-06-03 19:11 gore

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