comp.lang.ada
 help / color / mirror / Atom feed
From: GILBERT@YALEVMX.BITNET
Subject: Overloading procedures with objects
Date: Wed, 11-Jun-86 15:28:00 EDT	[thread overview]
Date: Wed Jun 11 15:28:00 1986
Message-ID: <8606112104.AA28684@ucbvax.Berkeley.EDU> (raw)


    The problem with procedure parameters, it seems to me, is as
much a question of overloading resolution as type checking. Once
the language rules were set up, the designers may have written
themselves into a corner which precludes procedure arguments. Two
items trouble me:

       Anyproc("+");

Today this will match a procedure of that name with a string
argument. With procedure arguments, it is now overloaded on all
procedures named Anyproc which take function arguments with darn
near any two arithmetic arguments. Furthermore, even if you added
procedure-types to the language you could not resolve the
overloading since "+" is builtin and is therefore an anonymous
procedure type (just as numeric literals are formally of type
"universal_integer" which is anonymous and never explicitly
defined. There is no reasonable way to state just what "+" you
mean.

    A somewhat less difficult problem is posed by the convention
that enumeration literals are syntatically treated as
parameterless functions which return a value of the enumeration
type. Today it is possible:

type PLACE is (IN, OUT);
procedure WHERE(X:PLACE);

But now if I could declare another WHERE which took as its
argument a "Function without arguments which returns PLACE" and
then wrote:

    WHERE (IN);

Which of the two separate WHERE routines am I calling. How
syntatically can I qualify IN to distinguish whether I want it
evaluated (to produce a value of type PLACE and call the first
WHERE) or left as a procedure (to call the second one).  More
importantly, do I want the compiler to have to deal with
overloading between symbols which are not just of different types
but also really of qualitatively different categories.

    It may be possible to define extentions of a language like
PASCAL which do type checking on procedure parameters, but the
language will not have overloading. It may even be possible with
great difficulty to define a language with overloading and
parameter procedures. But I do not think that the process will
survive the syntatic peculiarities that Ada introduced when
permitting redefinable primitives, derived functions, and
overloaded enumeration literals.

             reply	other threads:[~1986-06-11 19:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1986-06-11 19:28 GILBERT [this message]
1986-06-13 14:08 ` Overloading procedures with objects jankok
replies disabled

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