Re: Integer BASIC's "*** NO END ERR"
- From: Paul Schlyter <pausch@xxxxxxxxxxxxx>
- Date: Mon, 27 Jun 2005 08:44:28 +0200
In article <LxHve.4686$mw1.3996@trnddc09>, inexorabletash@xxxxxxxxxxx
says...
>Paul Schlyter wrote:
>
>> You must put an end to programs in other programming languages too.
>> If you omit the final END from a Pascal or FORTRAN program, or the
>> final closing brace from a C, C++, Java or C# program, the compilers
>> will treat this as a compilation error, forcing you to add the
>> missing END (or final closing brace), and recompile.
>
>The END statement is more akin to an exit() call (in C/C++) than a closing
>brace. An exit() call means "terminate execution now".
>
> In compiled languages like C/C++, braces (etc) are part of the syntax, and
> are (usually) strictly required. The use of statements like END or calls
> like exit() are simply part of the language's runtime services, and can
> hardly be required - many programs never stop!
An Integer Basic program which never stops doesn't need an END statement....
And you're of course right that the "END" in Integer Basic is more like
an "exit(<returncode>)" in C/C++.
BTW some compiled languages had both. FORTRAN for instance had END
which maked the end of a compilation unit (the main program, or a
subroutine), and it also had a STOP statement which stopped execution
of the program. In early FORTRAN systems, a main program without a STOP
would "run off the END" and start executing whaetever garbage resided
there as if it was machine language - later the compilers had "learnt"
to insert the equivalent of "STOP" in the code if a "STOP" statement
was missing. The situation was similar in subroutines except that
there one used RETURN instead of STOP -- in later FORTRAN's, if RETURN
was missing, END would generate the code for returning to the caller.
When multitasking was introduced on these early FORTRAN systems, "STOP"
was still generating a "HALT" machine instruction, stopping not just the
program but the whole system!! For some time programmers then had to use
"CALL EXIT" instead to terminate their programs gracefully.
>(Although on modern systems they usually have some contract with the OS to
>be asked to shut down nicely.)
>
>In most interpreted languages - like JavaScript, shell/batch files, Perl,
>etc - no explicit "end" statement is required. When the interpreter runs out
>of things to interpret, it stops nicely and hands execution back to the
>host.
Batch files, Perl and AWK are OK as examples of this, but Javascript is
not a good example: it's a language usually embedded in HTML, where
snippets of code is called. Such Javascript code doesn't contain any
"main program", it's just a collection of subroutines. And, yes, the
closing brace *is* required in Javascript.
BTW "interpreted languages" can be compiled too. Integer Basic had at least
two compilers (Flash!, and Galfo's Integer Basic compiler). There have been
Perl compilers as well as compilers for MS-DOS batch files. Writing a
compiler for MS-DOS batch files ought to be easy: apart from a few
"internal" batch commands, everything else will be "system" calls with the
specified command line....
> (Nothing wrong with Integer Basic's requirement for END - it probably cut
> down on errors when subroutines were later added to the "end" of the source.
> I'm certain I made mistakes like that.)
>
> Joshua
--
Paul Schlyter, Grev Turegatan 40, SE-114 38 Stockholm, SWEDEN
e-mail: pausch at saaf dot se
WWW: http://stjarnhimlen.se/
.
- References:
- Integer BASIC's "*** NO END ERR"
- From: Zorin the Lynx
- Re: Integer BASIC's "*** NO END ERR"
- From: Don Bruder
- Re: Integer BASIC's "*** NO END ERR"
- From: Paul Schlyter
- Re: Integer BASIC's "*** NO END ERR"
- From: Joshua Bell
- Integer BASIC's "*** NO END ERR"
- Prev by Date: Re: SVD (Semi-Virtual Diskette) support for Apple ][s now documented
- Next by Date: Re: SVD (Semi-Virtual Diskette) support for Apple ][s now documented
- Previous by thread: Re: Integer BASIC's "*** NO END ERR"
- Next by thread: Re: Integer BASIC's "*** NO END ERR"
- Index(es):
Relevant Pages
|