Special variables: Difference between revisions

Line 649:
 
=={{header|Fortran}}==
Fortran offers no special variables such as Pi, e, etc. as a part of the language, not even the modern special floating-point "values" such as NaN. Indeed, the syntax has no reserved words generally so that <code>GOTOGO TO</code> could be the name of a variable without damage to GO TO statements, though it is generally agreed that calling a variable END is provocative... It does have some ''numbers'' that are special: 5 is the input/output "unit number" for keyboard input and 6 for output to "standard output", the screen on desktop computers; in the past there have been other values that were associated to devices such as the card reader, card punch, lineprinter, paper tape reader, and so on at any given installation. But these constants are not given names as mnemonics for their special values, except by the programmer. There is no equivalent of SYSOUT as in WRITE(SYSOUT,''etc'' without definition by the programmer.
 
Certain statements involve special names in what appear to be assignments of values to or from a special name that has a value just like a named variable does, but these are ''not'' proper variables at all. For instance, in <lang Fortran> INQUIRE(FILE = FILENAME(1:L),EXIST = EXIST, !Here we go. Does the file exist?
Line 655:
IF (EXIST) THEN !So, does the named file already exist?
...etc.</lang>
ERR is a special name, but only inside the context of the INQUIRE statement (and OPEN, and WRITE, ''etc.'') statement, it is not the name of an existing variable outside that statement whether defined by the language or by the programmer, and if the programmer were to define a variable called ERR it would have no relevance within that INQUIRE statement, - though <code>ERR = ERR</code> ''would'' be workable if an ASSIGN statement had assigned statement label 666 to variable ERR. Similarly, the variable named FILENAME is declared by the programmer and because there are no reserved words, could be just FILE. Likewise, EXIST is declared (as LOGICAL) and IOSTAT (as INTEGER) as a mnemonic aid and also to save on the trouble of remembering whether the assignment works left-to-right or right-to-left in each case. It is right-to-left for FILE = ''filename'', input to the INQUIRE statement and left-to-right for EXIST = ''variable'', an output of the INQUIRE statement.
 
=={{header|Go}}==
1,220

edits