[comp.lang.modula2] Ambiguity?

darryl@ism780c.UUCP (12/10/86)

Does VAL introduce an abiguity into Modula-2?  Consider:
    :
    :
PROCEDURE Foo: INTEGER;  BEGIN RETURN 0; END;
    :
...VAL(POINTER TO ..., Foo)...;

How does the compiler decide whether "Foo" in this position denotes a
PROCEDURE or the INTEGER returned from an invocation of Foo?  I realize that
VAL is particularly machine dependent, and that my example above may only have
meaning for a particular, known, implementation;  even so, this appears to be
allowed and ambiguous.  In particular, I wonder why Wirth allows invocation to
be specified with or without the empty argument list;  this redundancy seems
particularly strange when contrasted with the spareness of the rest of the
language.

	    --Darryl Richman, INTERACTIVE Systems Corp.
	    ...!cca!ima\
			>-!ism780c!darryl
	    ...!sdcrdcf/
	    The views expressed above are my opinions only.

P.S.  The implementation I use, from Wirth's group, has an "implementation
restriction" and requires that I include the empty argument list when I want
an invocation.  In ambiguous circumstances such as this, I must code
"VAL(POINTER TO..., ADR(Foo))", if I want the PROCEDURE and "VAL(POINTER
TO..., Foo())" if I want the invocation.

bobc@tikal.UUCP (Bob Campbell) (12/12/86)

In article <4839@ism780c.UUCP> darryl@ism780c.UUCP (Darryl Richman) writes:
>...VAL(POINTER TO ..., Foo)...;
>How does the compiler decide whether "Foo" in this position denotes a
>PROCEDURE or the INTEGER returned from an invocation of Foo?
....
>P.S.  The implementation I use, from Wirth's group, has an "implementation
>restriction" and requires that I include the empty argument list when I want
>an invocation. 

It was my understanding that it is not a implementation restriction
which required the empty parameter list, but instead a design feature
of the language that all function calls must have a parameter list.
(This is just like "C" except that "C" requires a empty argment list
for any invocation even non functions).  Wirth's EBNF syntax for the
language does not show this, but there are some other things it does
not show also.  I suppect that in combining PROCEDURES and FUNCTIONS
into one syntax that a restriction that required a argument list was
left out.

I may be wrong, but I have never seen a modula-2 compiler which
allowed:

PROCEDURE x:INTEGER;
....

Bob Campbell
Teltone Corporation		18520 - 66th AVE NE
P.O. Box 657			Seattle, WA 98155
Kirkland, WA 98033

{amc,dataio,fluke,hplsla,sunup,uw-beaver}!tikal!bobc
bobc@tikal.teltone.com