Eloquence B.08.20 introduces support for the NLN ("No Line Numbers") mode
to overcome the need for unique line numbers. This removes a limit on the
code size in memory and allows efficient on demand loading of code.
When the NLN mode is enabled subroutines loaded with LOAD SUB (or on demand
loaded code) is no longer renumbered, retaining its original line numbers.
As a consequence line numbers are no longer unique across program segments
when executing an application. Line numbers continue to be unique per
program segment and in program files on disk.
With few exceptions Eloquence does not depend on unique line numbers at
runtime and almost all existing applications are expected to be able to take
advantage of the NLN mode.
Overview
As readers familiar with Eloquence may expect NLN mode mostly affects program
editing and debugging using the text based development environment.
Eloquence applications rarely use line numbers outside the current program
segment (subroutine or function) and the Windows based development environment (IDE)
does not rely on program program line numbers.
When using NLN mode, Eloquence makes a difference between a program code loaded
with LOAD and additional program segments (subroutine or multiline function) loaded
with LOAD SUB.
A program segment (subroutine or multiline function) loaded with LOAD SUB
(or loaded on demand) is considered an "NLN segment". A program segment (main
program, subroutine or multiline function) that is loaded with LOAD is not
considered a NLN segment and not affected by NLN mode.
When editing or debugging a program in NLN mode in the text based development
environment line numbers are context specific.
-
When the program is not running line numbers are unique and behavior
is unchanged.
-
When the program is running any NLN segments are hidden unless it is currently
active.
-
When executing in a non NLN segment lines in a NLN segment can't be modified.
-
When executing in a NLN segment lines outside this segment can't be modified,
any line numbers refers to this program segment.
Summary of differences
-
Subprograms loaded by LOAD SUB (or loaded on demand) are no longer
renumbered.
-
Line numbers are unique per program segment but not necessarily
unique for the entire program in memory.
-
Segments loaded with LOAD SUB are by no longer visible (to LIST) and are
discarded automatically once the program stops.
-
When storing a program any subroutines loaded with LOAD SUB are excluded.
-
Renumbering the program will convert segments loaded with LOAD SUB to
become part of the main program.
-
Segments loaded with LOAD SUB are visible to LIST only while they are
executed. At this point they may be modified as usual. However, any
modification is limited to the current program segment and will be
lost once the program stops.
Other program segments (or the original program) cannot be modified while
executing an autoloaded subroutine.
Enabling NLN mode
The Eloquence NLN mode needs to be enabled. By default it is
disabled to ensure full backwards compatibility.
There are two options how NLN mode may be enabled.
-
The OPTION NLN 1 may be specified in the Eloquence config file.
OPTION NLN 1
-
The option -nln may be specified on the eloqcore command line.
This is mostly useful for testing and may be removed in future
versions.
Statement details
LOAD SUB
Segments loaded with LOAD SUB are marked as NLN when the option
NLN is enabled or the LOAD SUB was executed from a NLN segment.
NLN segments are not renumbered but retain the original line number
when loaded.
REN
If the RENumber statement is executed from an NLN (or on demand loaded) segment
it will only affect this segment. This allows to editing or debugging NLN segments.
When RENumber is used when not executing in a NLN segment it will renumber the
program and remove the NLN flag from a segment loaded with LOAD SUB.
On demand loaded segments behave differently. They are not affected by the
RENumber and are still considered loaded on demand.
DEL
If the DEL statement is executed from an NLN segment it will only affect this segment.
This allows editing or debugging NLN or on demand loaded code segments.
Otherwise the DEL statement will not affect any autoloaded code.
DEL SUB / DEL FN
Unchanged. Autoloaded and NLN segments may be deleted.
SAVE / RE-SAVE
If the SAVE statement is executed from a NLN segment it will only affect this segment.
Otherwise the SAVE statement will not affect any autoloaded code unless the code is
currently busy. In this case the file created with SAVE may not be usable with GET as
line numbers are not guaranteed to be unique.
LIST
If the LIST statement is executed from an NLN segment it will only affect this segment.
Otherwise the LIST statement will not output any autoloaded code unless the code is
currently busy.
LIST SUB / LIST FN
The LIST SUB statement will list any subroutine or multiline function. Only the first
occurrence of a subroutine or multiline function is listed.
FETCH
Same as LIST.
STORE / RE-STORE
The STORE statement ignores any NLN segments.
GET / LINK / MERGE
If the statement is executed from an NLN segment it will only affect this segment.
A segment change (defining a new subroutine or multiline function) is not be allowed
in this case.
Otherwise the statement will not affect any NLN or autoloaded code.
Line Numbers
Line numbers do not mix well with automatic code management.
When using the NLN option, Line numbers are still present but
may no longer be unique across program segments. Line numbers
retain the same value as in the
program file they have been loaded from (no renumbering is performed).
Line numbers are still unique within a specific program segment,
so it is valid (but discouraged) to continue using them within a
program segment.
However, using line numbers across segments is undefined and may
result in a run-time error or dynamically loaded segments to be ignored.
Backwards compatibility
NLN mode is expected to be compatible with almost all existing applications.
However, referencing line numbers outside the current program segment will not
work when executing in NLN segments.
Consider the following examples:
10 DEL 100,200
100 ! Del from here
200 ! To here
210 STOP
This deletes the program lines 100 to 200. This will not be affected as
line numbers are referenced in the same program segment.
10 DEL 100,200
20 STOP
100 SUB X
110 ! Test
200 SUBEND
This example, again deletes the program lines 100 to 200. However, in this
case the affected lines are in a different segment. This will continue to
work as before when executed outside a NLN segment but ignore any NLN segments
that may happen to use the same line numbers. When executed in a NLN segment
the line numbers must refer to the same segment.
|