KeyWord
Re: KeyWord
As far as I can tell the only keywords are "VAR", "IN", & "OUT".
"ABSTRACT", EXTENSIBLE", & "LIMITED" are reserved words, which "cannot be used as identifiers" (paragraph 3.5).
So the ObxKW module looks illegal, and should be rejected by the compiler.
If (I haven't tested it myself) adding the line in luowy's post of 3-Dec-2017 implements that behaviour I would support it.
"ABSTRACT", EXTENSIBLE", & "LIMITED" are reserved words, which "cannot be used as identifiers" (paragraph 3.5).
So the ObxKW module looks illegal, and should be rejected by the compiler.
If (I haven't tested it myself) adding the line in luowy's post of 3-Dec-2017 implements that behaviour I would support it.
Re: KeyWord
If in module ObxKW I replace "ABSTRACT" by "EMPTY" it still compiles. So the problem (if it is a problem) is more general than currently reported.
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: KeyWord
How can a name (NEW) be a standard procedure AND a reserved word at the same time?
It can be either the one or the other, but not both. Or can it?
- Josef
It can be either the one or the other, but not both. Or can it?
- Josef
Re: KeyWord
VAR, IN, & OUT are both keywords & reserved words, so maybe there is no problem with NEW being two things. But NEW is not a reserved word (see para 3.5), so this question does not arise.Josef Templ wrote:How can a name (NEW) be a standard procedure AND a reserved word at the same time?
It can be either the one or the other, but not both. Or can it?
In the module
Code: Select all
MODULE RdcReserved;
PROCEDURE Do*;
VAR
xxx : INTEGER;
BEGIN
END Do;
END RdcReserved.
Those that cause 1 (or more) compilation errors are: ARRAY, BEGIN, BY, CASE, CLOSE, CONST, DIV, DO, ELSE, ELSIF, END, EXIT, FOR, IF, IMPORT, IN, IS, LOOP, MOD, MODULE, NIL, OF, OR, OUT, POINTER, PROCEDURE, RECORD, REPEAT, RETURN, THEN, TO, TYPE, UNTIL, VAR, WHILE, WITH.
Re: KeyWord
NEW appears to be a predeclared identifier, a standard procedure, and a method attribute.cfbsoftware wrote:The fact that NEW has a split personality being both a predefined object and a keyword makes it an exception ...
It does not appear to be a keyword or a reserved word.
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: KeyWord
Robert, what is the difference between a reserved word and a keyword?
- Josef
- Josef
Re: KeyWord
Do searches in the Language Report:
- "keyword" only appears in paragraph 10.1 to describe "IN", "OUT", or "VAR"
- "reserved" only appears in paragraph 3.5 and describes "ABSTRACT", ..., "WITH".
- "keyword" only appears in paragraph 10.1 to describe "IN", "OUT", or "VAR"
- "reserved" only appears in paragraph 3.5 and describes "ABSTRACT", ..., "WITH".
-
- Posts: 204
- Joined: Wed Sep 18, 2013 10:06 pm
- Contact:
Re: KeyWord
NEW isn't both 'at the same time' - it can be context sensitive. Consider this example:Josef Templ wrote:How can a name (NEW) be a standard procedure AND a reserved word at the same time?
It can be either the one or the other, but not both. Or can it?
Code: Select all
MODULE CfbNew;
TYPE
T = RECORD i: INTEGER END;
VAR
ptr: POINTER TO ARRAY OF CHAR;
i: INTEGER;
PROCEDURE P0;
BEGIN
NEW(ptr, 10)
END P0;
PROCEDURE (VAR t: T) P(x: INTEGER), NEW;
BEGIN
END P;
PROCEDURE NEW(VAR i: INTEGER);
BEGIN
i := 0
END NEW;
BEGIN
NEW(i);
NEW(ptr, 10)
END CfbNew.
Re: KeyWord
In don't really understand why this conclusion follows. The conclusion I draw is that it is unhelpful for a programmer to redefine any of the predeclared identifiers. If I had called the procedure ASSERT or ORD rather than NEW I would regard that as a bad idea.cfbsoftware wrote:This only goes to show that the decision to reuse the name of a standard procedure (identifier) as an attribute (reserved word) was not a good one.
Calling it ORD I would loose a useful language feature. Calling it NEW I loose two. Isn't the genie the fact that predeclared identifiers can be redefined at all?
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: KeyWord
There is no distinction between a keyword and a reserved word here.Robert wrote:Do searches in the Language Report:
- "keyword" only appears in paragraph 10.1 to describe "IN", "OUT", or "VAR"
- "reserved" only appears in paragraph 3.5 and describes "ABSTRACT", ..., "WITH".
It is used as a synonym. Keyword is just a slightly shorter and less precise word.
- Josef