Re: Integer BASIC's "*** NO END ERR"



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/
.



Relevant Pages

  • Re: a dozen cpus on a chip
    ... there are several compilers still available which implement ISO M2. ... By the time the full spec was published most industrial people had moved to other languages for purely commercial reasons. ... Some of the better static analysis tools for Modula2 can see into the program and find very deep faults that would not be found in normal execution. ... It is a common misconception that Lisp is always interpretted. ...
    (sci.electronics.design)
  • Re: what is the most suitable Linux platform for Programmers and software developers
    ... C, C++, Perl, Python, Lisp, and a bunch of other languages are supported ... There are FORTRAN compilers, but FORTRAN ... Look at the Linux ...
    (comp.os.linux.misc)
  • Re: Why forth is not popular
    ... >easily available books anymore. ... Well, looking at higher-level languages (I assume you mean languages, ... not compilers), the Lisp systems I have experienced do pretty much the ... but most programmers prefer plain source files. ...
    (comp.lang.forth)
  • Re: Mainframe vs. Supercomputer
    ... Suitable languages for writing compilers in ... system vendor compilers) portability ... better than Fortran 66, unless you favoured BCPL. ...
    (comp.arch)
  • Re: animation js function
    ... Javascript is not C.;) A C compiler can do a great deal of recognising ... You have already said that C compilers will optimise that from ... readability then ... var numVar = Number; ...
    (comp.lang.javascript)