T.R | Title | User | Personal Name | Date | Lines |
---|
123.1 | Semi-reserved words | TLE::HOBBS | | Mon Jan 19 1987 16:13 | 26 |
| VAX PASCAL invented the concept of "semi-reserved words" to handle this
situation. Usually a semi-reserved word had a special, built-in,
compiler-defined meaning. However, if the user defined an identifier
with a spelling identical to a semi-reserved word then (1) a warning
was generated, (2) the identifier was given its new definition, and
(3) the semi-reserved word no longer had its special, built-in meaning
(outside the scope of the identifier with the same spelling, the semi-reserved
word kept its built-in meaning).
Example of semi-reserved words are OTHERWISE, REM, VALUE and MODULE.
The concept of semi-reserved words allows VAX PASCAL to compile standards
conforming programs that use identifiers spelled the same as reserved words
introduced by VAX PASCAL extentions. It also means the addition of semi-
reserved words in future product releases will no invalidate customer programs
designed for earlier releases.
Note: BLISS-11 from CMU allowed any reserved word to be redefined as
a user identifier (it was often necessary to use $QUOTE to do this). This
feature was required when BLISS-11 was updated to include the co-routine
feature of BLISS-10 which used LENGTH as a reserved word. Too many earlier
BLISS-11 programs used LENGTH as an identifier so allowing reserved words
to be redeclared kept these older programs running. Of course, any program
that used LENGTH as a user identifier had limited use of the co-routine facility
in the scope of that identifier. Digital dropped the ability to redeclare
reserved words when it defined BLISS-16 and the other common BLISSes.
|
123.2 | It's a problem in TPU also | DSSDEV::TANNENBAUM | TPU Developer | Mon Jan 19 1987 18:03 | 9 |
| In TPU, we've defined numerous new keywords in our up-coming version.
They have unusual names like "LEFT", etc.
We're getting around this problem by letting locals variables (but
not globals) occlude keywords and builtins. Our compiler will generate
an informational message, so those users who care can rename the
preempted variables.
- Barry
|
123.3 | vocabulary level | OMEGA::CLARK | | Tue Jan 20 1987 17:37 | 9 |
|
I'd like to see languages use the notion of a "vocabulary level". A given
module would have a declaration saying "the following code unit uses the
builtin vocabulary published with standard #X, or release #X". Then for
recompilation of old code I would not have to put up with compiler warning
messages and I wouldn't have to change the source.
Paul Clark
|
123.4 | | SMOP::GLOSSOP | Kent Glossop | Tue Jan 20 1987 20:05 | 17 |
| You could just use PL/I - there aren't ANY reserved words (and your
example is one of the reasons why.) On the other hand, it does make
it possible for people to write very unmaintainable code... (Just
because the compiler's parser can get it right doesn't mean that someone
trying to read the code can...)
declare (if,then,else) entry(entry) returns(entry);
/* Declares the functions "if", "then" and
"else" */
if if=if(if)
then
if(else)=then(else);
else
else(if(then))=then(else(if(then)));
Kent Glossop
VAX PL/I
|
123.5 | | QUARK::LIONEL | Three rights make a left | Wed Jan 21 1987 09:30 | 4 |
| FORTRAN has no reserved words either. At the other extreme, Ada
has reserved words, but no implementation is allowed to add to the
list.
Steve
|
123.6 | | PEANO::GLASER | Steve Glaser DTN 226-7646 LKG1-2/A19 | Wed Jan 21 1987 13:15 | 31 |
| C also has reserved words. The standard does not allow you to
extend the list. Did that stop us? No way. We added:
globaldef
globalref
globalvalue
readonly
noshare
variant_struct
variant_union
We did, however, eliminate the reserved word "entry". It was in the
list in Kernighan and Ritchie (the "standard" of the time), but the
language didn't use it -- it was "reserved for future use".
It wouldn't be so bad if we documented our changes. The last two in
the list above (variant_*) were only recently documented in the
release notes for 2.3 but have been there since 2.0 (perhaps their
complete lack of utility had something to do with the lack of
documentation :-).
Who knows what other reserved words are lying there waiting to
trip up unsuspecting customers (and not just in C)?
To be fair, the C standard didn't exist at the time the compiler was
written and is still only in draft form. The DEC extentions dealing
with storage classes are actually even useful (some of which are now
in the standard, albeit in an incompatable syntax to what we did).
Steve Glaser
|
123.7 | | PEANO::GLASER | Steve Glaser DTN 226-7646 LKG1-2/A19 | Wed Jan 21 1987 13:18 | 9 |
| Fortran (old ones at least) even allowed you to run everything
together without spaces. The compiler didn't know the statement
DO10I=1,100
was a loop until it hit the comma. Until the comma everything
looked like an assignment statement.
steveg
|
123.8 | Are you sure? | TLE::RMEYERS | Randy Meyers | Wed Jan 21 1987 17:07 | 7 |
| Re: 123
> C also has reserved words. The standard does not allow you to
> extend the list.
Do you have a quote for that? My copy of the draft standard (July 1986)
even contains suggested common extensions: asm, entry, fortran...
|
123.9 | Invariant assertion | NOBUGS::AMARTIN | Alan H. Martin | Wed Jan 21 1987 17:12 | 29 |
| Re .6:
>... (perhaps their complete lack of utility had something to do with the
>lack of documentation :-).
The following is just as true today as it was yesterday:
/AHM
<<< TLE::PUBD$:[VAXNOTES]VAXC.NOTE;1 >>>
-< VAX C Notes >-
================================================================================
Note 638.4 variant aggregates 4 of 5
NOBUGS::AMARTIN "Alan H. Martin" 13 lines 20-JAN-1987 20:00
-< Real Programmers use them all the time >-
--------------------------------------------------------------------------------
Re .1:
> Not only are they of extremely limited utility, ...
The functionality provided by variant_union and variant_struct was vital in
the construction of discriminated union datatypes for a highly optimizing C
compiler I worked on last fiscal year. Given the same problems to be
solved, I'd use the same approach today.
If they weren't invented when they were, we would have asked for them
anyhow. All things considered, we might just have added something like
them ourselves to VAX C if they hadn't happened along for free in V2.0.
/AHM
|
123.10 | DO 10 I =1.10 | CRVAX1::KAPLOW | There is no 'N' in TURNKEY | Thu Jan 22 1987 18:16 | 19 |
| Re: .7
Ah, yes, one of my all time favorite Fortran user errors. A long
time ago in a galaxy far far away, I was a student at a CDC site,
where we actually used CARDS and KEYPUNCHES for programming! I
worked at the consultants desk, and someone came up with a program
tha wasn't working. Due to poor quality printout (worn ribbon and
hammers) it took us a long tome to notice the statement:
DO 10 I = 1.10
had a period where the comma should be. We couldn't figure out
what was going on, or why the compiler didn't flag the statement
as bad, until in the variable map, we found DO10I was defined. I'm
sure I'll never forget this one.
Fortran seems perfectly happy to let you have arrays called DATA,
variables called IF, etc. About the only thing that can trip it up
is use of FORMAT as an array name.
|
123.11 | Two Compiler's Opinions | TLE::RMEYERS | Randy Meyers | Thu Jan 22 1987 20:46 | 36 |
| Re .10:
>About the only thing that can trip it up is use of FORMAT as an array name.
Two FORTRAN compilers beg to differ:
On VMS:
$ ty x.for
INTEGER FORMAT(2)
I1 = 1
I2 = 2
I6 = 6
10 FORMAT(I1) = -100
20 FORMAT(I2) = -200
WRITE(5,30) FORMAT
30 FORMAT(I5)
END
$ fortran x
$ link x
$ run x
-100
-200
$
On TOPS-20:
@exec x.for
FORTRAN: X
MAIN.
LINK: Loading
[LNKXCT X execution]
-100
-200
CPU time 0.18 Elapsed time 0.97
@
|
123.12 | From NANDI::SWENG | MLOKAI::MACK | a(-M-~8#-861225:0825 | Fri Jan 23 1987 13:06 | 16 |
| Re .10:
Software Engineering Note #13 has a list of significant
software/hardware/etc bugs which have been covered in various
publications, some of which are somewhat familiar to the general
public. (I presume the list was pulled off the usenet.)
One entry --
Mariner 1: Atlas booster launch failure DO 100 I=1.10 (not 1,10)
I wonder how much mischief this one problem (the invisibility of
the difference between "," and "." on most primitive printing hardware)
has caused.
Ralph
|
123.13 | Whoops, try again | CRVAX1::KAPLOW | There is no 'N' in TURNKEY | Tue Jan 27 1987 12:19 | 5 |
| Re: .11
All right, I guess I got it wrong. After further thought, I think
it is a function or subroutine named FORMAT that may confuse SOME
Fortran compilers.
|
123.14 | Must be a bug | NOBUGS::AMARTIN | Alan H. Martin | Tue Jan 27 1987 16:53 | 33 |
| Re .13:
I guess those implementations have bugs in them, then. I can't think of
how subroutine names could appear in the same context as the keyword
FORMAT. And the only place I can think of a function name doing so is in
the definition of a statement function. The occurrence of an "=" following
the first outermost set of parens is sufficient to distinguish the two cases.
Someone showed me a confusing example of FORMAT in college, but it relied
upon a Hollerith constant 3H)=( in the format, or something like that,
and in retrospect I don't think it was actually ambiguous.
One of my favorite user errors is:
DOUBLE PRECISIONS X,Y
which declared two DP variables, SX and Y.
Striking somewhat closer to home, I leave it as an exercise to the reader
to determine whether the statement:
INTEGERFUNCTIONF
means
INTEGER FUNCTION F
or
INTEGER FUNCTIONF
in VAX Fortran, which supports long identifiers.
/AHM
|
123.15 | | QUARK::LIONEL | Three rights make a left | Tue Jan 27 1987 21:46 | 4 |
| The only source restriction on "reserved words" I can
think of in FORTRAN is that the ENDFILE statement must have the
word "ENDFILE" all on one line.
Steve
|
123.16 | ENDFILE | TLE::RMEYERS | Randy Meyers | Wed Jan 28 1987 02:47 | 13 |
| Re .15:
You came close, Steve. The restriction is only that you can not choose
to put the "D" and "F" of ENDFILE on separate line (lines, hell, lets
call them card images like they really are!). Thus,
E
1N
2D F
3I
4L
5E
is OK.
|
123.17 | | TLE::HOBBS | | Wed Jan 28 1987 10:49 | 11 |
| Subscripted FORMAT causes a problem for compilers that try to accept
old FORTRAN II syntax as well as FORTRAN-66 and FORTRAN-77.
Consider:
100 FORMAT(X5H)=A(5)
In FORTRAN II this can only be a FORMAT statement. In FORTRAN-66 and
FORTRAN-77 it can only be an assignment statement (or statement function
definition). Although VAX FORTRAN does accept FORTRAN II syntax FORMATs,
in this situation it breaks the ambiguity by following FORTRAN-77 and
making this an assignment statement.
|
123.18 | Lucky there is no Fortran-II validation test suite | NOBUGS::AMARTIN | Alan H. Martin | Wed Jan 28 1987 14:03 | 6 |
| Re .17:
A-HAH!
Yep, that's what I was thinking of.
/AHM/THX
|
123.19 | INTEGER FUNCTIONF and INTEGER FUNCTION F() | SMURF::JMARTIN | Bang the rocks together. | Fri May 29 1987 12:27 | 21 |
| re .14
>>...I leave it as an exercise to the reader to determine whether the statement:
>>
>> INTEGERFUNCTIONF
>> means
>> INTEGER FUNCTION F
>> or
>> INTEGER FUNCTIONF
>>
>>in VAX Fortran, which supports long identifiers.
>> /AHM
Alan,
It's been three more years since I was implementing a FORTRAN compiler
than it's been since you were. If I remember my parser generator correctly,
a FUNCTION with no arguments must have a pair of parentheses (()) after the
name of the function. I opt for number two. Is that a correct analysis?
I know I could just ask the VAX FORTRAN compiler, but to do that I'd have
to find (and perhaps install) one here in ULTRIXland.
--Joe
|
123.20 | Nope, that won't disambiguate it | DENTON::AMARTIN | Alan H. Martin | Fri May 29 1987 19:11 | 5 |
| I don't have a standard handy, but I think you are thinking of function
*invocations* requiring the empty parens. I think that declarations
may omit them with impunity according to the standard. VAX Fortran
certainly lapped it up with no problems just now.
/AHM
|
123.21 | cheat and look at where it is | TLE::MCCUTCHEON | May all your mousse be chocolate | Tue Jun 02 1987 14:11 | 10 |
| What we did for Fortran-10/20 is what VAX Fortran does. For:
INTEGERFUNCTIONF
INTEGERFUNCTIONF
END
it compiles without error. The first statement declares a function
named F. The 2nd a variable named FUNCTIONF. You can tell whether
you had a beginning PROGRAM/FUNCTION/SUBROUTINE/DATA statement and
from that its either a function or variable declaration.
|
123.22 | Re: .4, uses invalid PL/I | STARCH::JSLOVE | | Tue Dec 01 1987 15:43 | 39 |
| For PL/I, the archetypical silly statement is something like:
if then = else
then else = if;
else if = then;
That works fine, provided that if, then and else are of types which
can be converted to each other, and either all scalar or are all
arrays of conforming dimension. If you don't mind warnings, you
don't even have to declare them.
The example given in .4 included two excerpts which were invalid PL/I.
Both have the same problem; the simpler one is given below.
if (else) = then (else);
Given that "if" is neither an array, nor builtin pseudo-variable, but
instead is a function, the presence of an argument list makes this an
expression, and expressions are not permitted to the left of the
assignment operator. Only references are permitted, although
references can contain expressions as subscripts, certain parameters of
pseudo-variables, or preceding a pointer qualifier ("->").
The designers of PL/I got around having reserved words by reserving
all the simple and compound delimiters, and basing the syntax on
the delimiters.
In COBOL, the archetypical silly statement was mildly obscene. I'm not
sure whether including it in this notesfile would violate Digital
policy. The expurgated statement below is a looping subroutine call.
PERFORM LABEL1 THROUGH LABEL2
VARYING VARIABLE1 FROM 1 TO 12
UNTIL VARIABLE2.
The substitutions are left as an exercise to the reader.
Spencer Love
File Storage Architecture
|
123.23 | | SMOP::GLOSSOP | Kent Glossop | Wed Dec 02 1987 15:10 | 4 |
| RE: .22
[Blush] Right. I must have been working too hard (on PL/I V3 features)
at the time to make such an obvious error...
|
123.24 | case of reserved words and prefix characters | COOKIE::DOUCETTE | Chuck Doucette, Database A/D @CXO | Wed Mar 09 1988 23:24 | 28 |
| The language/compiler our group uses for implementation is DECWRL Modula-2.
It raises some interesting issues about this topic.
Capitalization of reserved words and standard/built-in identifiers is not
forced (the default is to allow each identifier in any combination of case),
until you tell the compiler to do this. For example,
END = end = End
But, for user-defined identifiers, the compiler *is* case-sensitive.
Unfortunately, some modula-2 programs take advantage of the fact that this is
non-standard behavior, and create variables with the same name as a reserved
identifier.
A reserved word can not be used as a user-defined identifier unless you turn
the standard-case switch on (and the user-defined identifier isn't all in
upper-case). A built-in or standard identifier can sometimes be redefined. For
example, if you have to import it, you can define/import your own identifier
of the same name.
Finally, this compiler adds many reserved words. These are set off from the
standard reserved words by adding a prefix character of '@' (e.g. @align,
@size, @inline, @dynarray ...). Other compilers add non-standard keywords with
the prefix '%'.
Chuck
|