From: | Dave Thompson <david.thompson1@worldnet.att.net> |
Newsgroups: | comp.compilers |
Date: | 2 Nov 2004 12:10:00 -0500 |
Organization: | AT&T Worldnet |
References: | 04-10-092 04-10-161 |
Keywords: | syntax, design |
Posted-Date: | 02 Nov 2004 12:10:00 EST |
On 21 Oct 2004 22:31:31 -0400, Paul Robinson
<postmaster@paul.washington.dc.us> wrote:
> M Cleary wrote:
> > ruby and python use "def"
> So does Lisp.
And classic BASIC for statement functions: DEF FNA(X)=X+3
LISP has several defining-words _beginning with_ DEF (DEFUN, DEFMACRO,
DEFCONSTANT, etc.) but I don't recall any using just DEF, and the only
reference I have to hand (a copy of the CommonLISP "Hyperspec"
downloaded from somewhere) certainly doesn't.
> > perl uses "sub"
> So does Visual Basic.
> > lua uses "function"
> So do C, Visual Basic, Pascal and Fortran.
C uses the term but not the keyword. OTOH Ada does.
The others do so only for valued routines; nonvalued ones are 'sub' in
VB, 'subroutine' in Ftn, 'procedure' in Pascal and Ada. But statement
functions in Fortran have no keyword, and in fact are a bit tricky to
disambiguate even for humans.
> > tcl uses "proc"
> So does PL/I.
PL/I actually used either full 'procedure' or abbreviation 'proc'. In
the days of 71-column-usable cards people did tend to abbreviate.
JCL <G><G> also used PROC although IIRC it had to be the first record
(line) in a procedure so the keyword was actually redundant.
<snip>
> You merely need something which either preceeds or follows one or the
> other to differentiate between [definition and use] ...
> The use of a flag on both define of a subroutine and when the subroutine
> is called comes from older languages where we did not have good theory
> on how to analyze language strings properly, i.e. Fortran, which was
Nonvalued SUBROUTINE + CALL yes, but not for valued FUNCTION.
> originally created in the late 1950s. Later languages - even COBOL
> which first came out only a short time later, eliminated defining a
> procedure. You just named it; you called it through PERFORM.
Not really; in classic COBOL a paragraph or section name had to begin
in columns 2-5 and an executable statement had to be in columns 6-up.
Threre was no keyword but there was a hard syntactic distinction. I
believe -85 relaxed this, or at least some -85 compilers I used did.
- David.Thompson1 at worldnet.att.net
Return to the
comp.compilers page.
Search the
comp.compilers archives again.