version 1.37, 2025/05/02 15:16:36
|
version 1.41, 2025/05/04 13:46:10
|
Line 7
|
Line 7
|
This manual is for FreeM, (version 0.64.0-rc1), which is a free software@footnote{FreeM subscribes to the software licensing philosophy described in @emph{Free Software, Free Society: |
This manual is for FreeM, (version 0.64.0-rc1), which is a free software@footnote{FreeM subscribes to the software licensing philosophy described in @emph{Free Software, Free Society: |
Selected Essays of Richard M. Stallman}.} implementation of the M programming language. |
Selected Essays of Richard M. Stallman}.} implementation of the M programming language. |
|
|
|
Print-optimized versions of this book are typeset in @emph{Computer Modern} by the author using the @emph{GNU Texinfo} tools. |
|
|
Copyright @copyright{} 2014-2025 Coherent Logic Development LLC |
Copyright @copyright{} 2014-2025 Coherent Logic Development LLC |
|
|
Line 44 This is the official manual for the Free
|
Line 45 This is the official manual for the Free
|
@menu |
@menu |
* Introduction:: About the FreeM Project, its history, and its goals. |
* Introduction:: About the FreeM Project, its history, and its goals. |
* Document Conventions:: Conventions used in this manual. |
* Document Conventions:: Conventions used in this manual. |
|
* A Note on Standards:: FreeM positioning regarding the M Development Committee. |
* FreeM Invocation:: How to invoke FreeM from the command line. |
* FreeM Invocation:: How to invoke FreeM from the command line. |
* The FreeM Environment Daemon:: Managing shared resources in the FreeM environment. |
* The FreeM Environment Daemon:: Managing shared resources in the FreeM environment. |
* The FreeM Direct-Mode Environment:: Executing M programs interactively. |
* The FreeM Direct-Mode Environment:: Executing M programs interactively. |
Line 117 When GT.M was open-sourced in late 1999,
|
Line 119 When GT.M was open-sourced in late 1999,
|
|
|
In February of 2020, work began in earnest to build a development and support infrastructure for FreeM and begin the careful process of refining it into a more stable and robust application. |
In February of 2020, work began in earnest to build a development and support infrastructure for FreeM and begin the careful process of refining it into a more stable and robust application. |
|
|
|
For more information on FreeM history, see @code{@emph{$PREFIX}/share/freem/doc/freem_history.*} (distributed in PostScript, PDF, and plain text formats). |
|
|
@section Production Readiness |
@section Production Readiness |
|
|
FreeM is not yet production-ready. There are several show-stopping bugs that preclude a general release for public use: |
FreeM is not yet production-ready. There are several show-stopping bugs that preclude a general release for public use: |
Line 276 Refers to the name of an M structured sy
|
Line 280 Refers to the name of an M structured sy
|
Refers to a truth-valued expression. |
Refers to a truth-valued expression. |
@end table |
@end table |
|
|
|
@node A Note on Standards |
|
@chapter A Note on Standards |
|
@cindex MDC |
|
@cindex M Development Committee |
|
@cindex ANSI X11.1 |
|
@cindex standards, ANSI |
|
@cindex standards, MDC |
|
|
|
FreeM attempts to implement as many features as possible from the M Development Committee's unpublished @emph{Millennium Draft Standard}, as well as its predecessors. |
|
|
|
The maintainer of FreeM (who is also the author of this book) is largely in favor of standardization efforts, and hopes that the MDC will resume activities, and will happily participate if it does so in an open, public, transparent, and democratic manner. Until then, however, FreeM will attempt to improve the M language, in cooperation with other free software M implementers where possible. Any breaking changes introduced in future MDC releases of the @emph{Standard} (such as the rumored @emph{M5}) which prove incompatible with FreeM will be handled via the @code{$DIALECT} special variable (to be changed to @code{$ZDIALECT} in a coming release). |
|
|
|
The conformance document required per the @emph{Standard} should be installed as a @code{man} page on any computer system where FreeM is made available. Simply type @code{man freem_conformance} to access. |
|
|
@node FreeM Invocation |
@node FreeM Invocation |
@chapter FreeM Invocation |
@chapter FreeM Invocation |
@cindex invocation, command-line |
@cindex invocation, command-line |
Line 2404 ELSE[@emph{:postcondition}]
|
Line 2422 ELSE[@emph{:postcondition}]
|
@quotation |
@quotation |
@emph{Non-Standard Behavior} |
@emph{Non-Standard Behavior} |
|
|
FreeM allows a @emph{postcondition} on @code{ELSE}. While explicitly forbidden in the @emph{standard}--and for good reason--it was decided that FreeM should allow postconditions everywhere, both for the sake of foolish consistency (the likes of which Emerson warned against), and for the benefit of entrants to a hypothetical future obfuscated M contest, and those with a Machiavellian predisposition to wicked perversions and undue cleverness. |
FreeM allows a @emph{postcondition} on @code{ELSE}. While explicitly forbidden in the @emph{Standard}, it was decided that FreeM should allow postconditions everywhere, both for the sake of foolish consistency (the likes of which Emerson warned against), and for the benefit of entrants to a hypothetical future obfuscated M contest, and those with a Machiavellian predisposition to wicked perversions and undue cleverness. |
|
|
Using postconditions on @code{ELSE} should be strictly avoided in production code, as they have no practical use, and may contribute to technical debt, hardening of the arteries, hobgoblins, a small mind, a surfeit of logic, climate change, @emph{Daily WTF} rants, or the meltdown of global financial markets. |
Using postconditions on @code{ELSE} should be strictly avoided in production code, as they have no practical use, and may contribute to technical debt, hardening of the arteries, hobgoblins, a small mind, a surfeit of logic, climate change, @emph{Daily WTF} rants, or the meltdown of global financial markets. |
@end quotation |
@end quotation |
Line 2559 IF[@emph{:postcondition}] @emph{tvexpr}[
|
Line 2577 IF[@emph{:postcondition}] @emph{tvexpr}[
|
|
|
In its argumentless form, allows the remainder of the line of code following @code{IF} to execute only if @code{$TEST} evaluates to @emph{1}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. |
In its argumentless form, allows the remainder of the line of code following @code{IF} to execute only if @code{$TEST} evaluates to @emph{1}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. |
|
|
|
|
@emph{Syntax} |
@emph{Syntax} |
@example |
@example |
IF[@emph{:postcondition}] |
IF[@emph{:postcondition}] @emph{command...} |
@end example |
@end example |
|
|
|
@cartouche |
|
@quotation |
|
@emph{Style Recommendation} |
|
|
|
In the interest of readability and maintainability, we recommend avoiding the argumentless form of @code{IF} in new code. It is an obsolete relic of an era when routine sizes were severely limited, and can be difficult to spot, as the use of whitespace (@code{IF @emph{command}}) makes the intent of its use non-obvious at a glance. It is also far too easy to inadvertently delete the extra space, leading to program errors easily avoided otherwise. |
|
|
|
We recommend explicitly checking the value of @code{$TEST} instead, as in @code{IF $TEST @emph{command}} or @code{@emph{command}:$TEST ...}, as this makes the intent immediately clear both to M newcomers and seasoned experts, and sacrifices nothing of value, even on the oldest computer systems where FreeM can be used today. |
|
@end quotation |
|
@end cartouche |
|
|
@node JOB |
@node JOB |
@section JOB |
@section JOB |
@cindex JOB |
@cindex JOB |
Line 4672 Transaction processing allows applicatio
|
Line 4701 Transaction processing allows applicatio
|
@section Transaction Processing |
@section Transaction Processing |
@cindex transaction processing |
@cindex transaction processing |
|
|
FreeM implements a significant subset of the transaction processing features from @emph{ANSI X11.1-1995}. This allows a series of global operations to be conducted all at once, either in batch mode (where concurrency is not disturbed), or in serial mode (where writes are guaranteed to be atomic, consistent, isolated, and durable). |
FreeM implements a significant subset of the transaction processing features from @emph{ANSI X11.1-1995}. This allows a series of global operations to be conducted all at once, either in batch mode (where concurrent operation is not interrupted until the last possible moment), or in serial mode (where writes are guaranteed to be atomic, consistent, isolated, and durable). |
|
|
@subsection Theory of Operation |
@subsection Theory of Operation |
|
|
Line 4751 The effect of this is that the operation
|
Line 4780 The effect of this is that the operation
|
@cindex variables, local |
@cindex variables, local |
@cindex local variables |
@cindex local variables |
|
|
|
@menu |
|
* Local Variables Overview:: The basics of locals. |
|
* Creating Local Variables:: Creating locals with SET. |
|
* Removing Local Variables:: Removing locals with KILL. |
|
@end menu |
|
|
|
@node Local Variables Overview |
|
@section Local Variables Overview |
|
|
|
FreeM @emph{local variables} have the same data structure as global variables, but are scoped to a single FreeM process, and stored in memory. |
|
|
|
Each local comprises three elements: |
|
|
|
@itemize @bullet |
|
@item |
|
An alphabetic name beginning with a letter or a percent sign (@code{%}) |
|
@item |
|
Optionally, one or more comma-delimited subscripts, enclosed in parentheses |
|
@item |
|
A value of up to 255 characters in length |
|
@end itemize |
|
|
|
@node Creating Local Variables |
|
@section Creating Local Variables |
|
@cindex local variables, creating |
|
|
|
To create a local variable, use the @code{SET} command: |
|
|
|
@example |
|
SET MYLOCAL("foo","bar")="this is the data value" |
|
@end example |
|
|
|
@node Removing Local Variables |
|
@section Removing Local Variables |
|
@cindex local variables, removing |
|
|
|
To remove an entire local variable, you can use the @code{KILL} command with the unsubscripted name of the variable: |
|
|
|
@example |
|
KILL MYLOCAL |
|
@end example |
|
|
|
If you only want to remove part of a local variable, i.e., beginning at a certain subscript level, use the @code{KILL} command with a subscripted name: |
|
|
|
@example |
|
KILL MYLOCAL("foo") |
|
@end example |
|
|
|
This will remove only the @code{"foo"} subscript and all of its children. |
|
|
|
If you only want to remove the data value at a specific subscript level, leaving the subscript itself intact, use @code{KVALUE}: |
|
|
|
@example |
|
KVALUE MYLOCAL("foo") |
|
@end example |
|
|
@node Scoping |
@node Scoping |
@chapter Scoping |
@chapter Scoping |
@cindex scoping |
@cindex scoping |
|
|
|
By default, FreeM local variables and their values are scoped to the entire process, meaning that any function or subroutine can access and modify their values. This can lead to pernicious bugs. |
|
|
|
M provides the @code{NEW} command to work around these issues. When @code{NEW} is called with a local variable as its argument, FreeM will scope the variable to the process stack frame in which the @code{NEW} command occured. When exiting the stack frame (i.e. with the @code{QUIT} command), FreeM will restore the variable to its value prior to being @code{NEW}ed. |
|
|
|
@emph{Example} |
|
|
|
@example |
|
MYRTN ; |
|
S J=1 ; set local variable J to 1 |
|
W J,! ; this will output "1" |
|
D X ; execute subroutine X |
|
W J,! ; this will output "1", as the value of J was restored |
|
Q |
|
;; |
|
X ; |
|
N J ; stack J |
|
S J=6 ; set its value to 6 |
|
W J,! ; this will output "6" |
|
Q ; quit from the subroutine, destroying its stack frame |
|
;; |
|
@end example |
|
|
|
@section Scoping Considerations for $TEST |
|
|
|
In M, the truth value of comparisons, logic operations, and certain forms of @code{LOCK} is stored in the @code{$TEST} intrinsic special variable, which follows the same rules as any M local variable. |
|
|
|
This is probably the most significant design flaw of the language, as the side effects of logic on @code{$TEST} lead to incredibly difficult bugs. However, M allows @code{$TEST} to be @code{NEW}ed, and FreeM provides the @code{THEN} command@footnote{From MDC Type A extension X11/1998-31} to help in the case of conditionals. @code{THEN} stacks @code{$TEST} to the end of the line. |
|
|
|
When writing new M code in FreeM, we strongly suggest using @code{THEN} as follows: |
|
|
|
@example |
|
MYRTN ; |
|
IF MYVAR=1 THEN DO SUBRT |
|
@end example |
|
|
|
This is instead of the traditional form: |
|
|
|
@example |
|
MYRTN ; |
|
IF MYVAR=1 DO SUBR |
|
@end example |
|
|
|
@cartouche |
|
@quotation |
|
@emph{Style Recommendation} |
|
|
|
Note that @code{THEN} is not in any currently published version of the @emph{Standard}, but is part of MDC Type A extension X11/1998-31. However, we recommend using @code{THEN} instead of favoring portability, as there is no defensible reason for this incredibly simple feature @emph{not} to be ubiquitous. |
|
|
|
If you use other M implementations, you should bug the implementers to implement @code{THEN}, as it at least partially mitigates an inexcusable flaw in the design of M. |
|
@end quotation |
|
@end cartouche |
|
|
@node Decision Constructs |
@node Decision Constructs |
@chapter Decision Constructs |
@chapter Decision Constructs |
@cindex decision constructs |
@cindex decision constructs |
Line 4813 The effect of this is that the operation
|
Line 4950 The effect of this is that the operation
|
* Class Overview:: Class basics. |
* Class Overview:: Class basics. |
* Constructors:: Managing object creation. |
* Constructors:: Managing object creation. |
* Destructors:: Cleaning up. |
* Destructors:: Cleaning up. |
|
* Inheritance:: Deriving classes from other classes. |
|
* Methods:: Adding code to classes. |
* Runtime Polymorphism:: Selecting methods at runtime. |
* Runtime Polymorphism:: Selecting methods at runtime. |
@end menu |
@end menu |
|
|