Thread View: comp.lang.modula2
2 messages
2 total messages
Started by darryl
Wed, 10 Dec 1986 01:05
Ambiguity?
Author: darryl
Date: Wed, 10 Dec 1986 01:05
Date: Wed, 10 Dec 1986 01:05
28 lines
1777 bytes
1777 bytes
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.
Re: Ambiguity?
Author: Bob Campbell
Date: Fri, 12 Dec 1986 00:41
Date: Fri, 12 Dec 1986 00:41
32 lines
1867 bytes
1867 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads