[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.1 Scoping Considerations for $TEST

In M, the truth value of comparisons, logic operations, and certain forms of LOCK is stored in the $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 $TEST lead to incredibly difficult bugs. However, M allows $TEST to be NEWed, and FreeM provides the THEN command(2) to help in the case of conditionals. THEN stacks $TEST to the end of the line.

When writing new M code in FreeM, we strongly suggest using THEN as follows:

MYRTN ;
  IF MYVAR=1 THEN DO SUBRT

This is instead of the traditional form:

MYRTN ;
  IF MYVAR=1 DO SUBR

Style Recommendation

Note that THEN is not in any currently published version of the Standard, but is part of MDC Type A extension X11/1998-31. However, we recommend using THEN instead of favoring portability, as there is no defensible reason for this incredibly simple feature not to be ubiquitous.

If you use other M implementations, you should bug the implementers to implement THEN, as it at least partially mitigates an inexcusable flaw in the design of M.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 5, 2025 using texi2html 5.0.