On Tuesday, 30 August 2016 18:22:01 UTC+9, Martin Brown wrote:
I think removing WITH is probably a mistake as using this
wisely makes code using records a lot more readable.
In principle yes, but such a facility should neither be limited to record instances nor to code blocks. Consider the case of type in an imported library.
IMPORT FooLib;
FooLib.Colour
I might want to write a procedure where the type is a parameter and I might want to use the type unqualified because the procedure header is already cramped with other parameters that make the parameter list unwieldy.
PROCEDURE DoDad ( ... ; colour : Colour ; ... );
You couldn't do this using WITH because it (a) is limited to record instances and (b) may only occur within a code block.
Also, the type may be an enumeration which in R10 requires qualification of each value with the type identifier, thus
FooLib.Colour.Red, FooLib.Colour.Green, ...
I might want to shorten this to Colour.Red, Colour.Green etc or I might even want to use the names entirely unqualified, either all of them (which increases the possibility of name conflicts) or just a few select ones I am interested in.
If I do that within a procedure, the unqualified alias would reasonably have procedure scope because if I use such an abbreciated name in a procedure at one point, I might use it again at other points within the same procedure. This would still limit the
possibility of name conflicts.
Again, you can't use WITH for doing that.
What is needed is a more general facility to establish an alias name in the current scope, equal to a lesser qualified name of a qualified name.
The M2 R10 grammar includes such a facility reusing reserved word ALIAS which was introduced for ALIAS types.
PROCEDURE DoDad ( ... );
ALIAS FOR FooLib.Colour, FooLib.Colour.*;
VAR colour : Colour; (* actually FooLib.Colour *)
BEGIN
...
colour := Red; (* actually FooLib.Colour.Red *)
I have not included an example in the comparison chart because there is a chance we might change the reserved word we use in the syntax.
An alias generally introduces a different name for an existing name and this is how we use ALIAS in the alias type constructor, its original purpose.
However, the name shortening facility does not permit definition of a different name, nor should it. Reuse of reserved word ALIAS may thus be misleading.
We could add an entry in our glossary and define "unqualified alias" to mean just that which the syntax is supposed to do, but it is perhaps better to find a more fitting reserved word for it. For example
UNQ FooLib.Colour, FooLib.Colour.*;
ABBREV FooLib.Colour, FooLib.Colour.*;
SHORTEN FooLib.Colour, FooLib.Colour.*;
In any event, this facility would take better care of your record scenario than WITH does. It's just a matter of finding a better name for it.
I'm inclined to think that the "T" in TMAX, TMIN etc is redundant.
M2 R10 uses MIN and MAX for predefined variadic functions that return the largest/smallest value of their argument lists.
The use of T prefixes is consistent with all other macros that take a type identifier as their argument. They look like functions but they are actually constants. See also TLIMIT and TSIZE.
I also reckon that HALT(status) should be promoted out of UNSAFE and
into predefined procedures. You want to encourage people to use it.
In M2 R10, HALT has abort semantics, which renders its use potentially unsafe.
What you want is RETURN status in the BEGIN ... END block of a module.
hope this clarifies.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)