[comp.std.mumps] Name handling functions

hokey@plus5.UUCP (Hokey) (03/25/88)

Title: Name handling functions

Advocate: Hokey <hokey@plus5.com>

History: 20 Mar 88 - Submitted

Abstract:
	A discussion and alternatives to the Name Handling Functions
	proposal (MDC-6, X11.1/87-12, or X11/SC1/TG10/88-1, as you wish)
	are presented.

	Page and section numbers are from X11/SC1/TG10/88-1 and X11/SC1/88-14.

Discussion:
	The proposal offers 3 new functions to aid in subscript processing.
	Plus Five has provided this functionality and more with a single
	function.  Specifically:

		Proposal			Plus Five
		$QLength(glvn)			$ZName(glvn,0)
		$QName(glvn)			$ZName(glvn)
		$QName(glvn,intexpr)		$ZName(glvn,1,intexpr)
		$QSubscript(glvn,intexpr)	$ZName(glvn,intexpr)

	I don't know that we need three functions for these tasks.

	Note the third example above.  The two argument form of $QName
	provides no way to extract "intermediate" subscript ranges; the
	value is always the name level through some other level.

	There is also a problem with the definition of "name value" (3.2.2.4),
	in that it assumes subscripts are either numlits or strlits.  While
	this is true for subscripts meeting the portability requirement,
	it is not true in general.  Specifically, a strlit cannot contain
	nongraphics.

	A more global deficiency is in the definition of lnamind.

	The following are (effectively) equivalent to a(1):

		a(1)
		@"a(1)"
		@"a"@(1)
	
	If
		@""@("a",1)

	was allowed as an extension to the [gl]namind syntax as a means
	to specify a(1), we would have a more consistent and powerful
	means to utilize and specify glvns and the name handling function(s).

Proposal:
	Replace the definitions of rlvn and lnamind in 3.2.2.1:

		rlvn ::= | name [ ( L expr ) ]    |
			 | @ lnamind @ ( L expr ) |

		lnamind ::= rexpratom V lvn

	with:

	    rlvn ::= | name [ ( L expr ) ] |
		     | lnamind             |

	    lnamind ::= | @ rexpratom V lvn @ ( L expr )		  |
		        | @ rexpratom V "" @ ( expr V name [ , L expr ] ) |

	Replace the second paragraph of 3.2.2.1:

		When lnamind is present it is always a component of an rlvn.
		If the value of the rlvn is a subscripted form of lvn, then
		some of its subscripts may have originated in the lnamind.
		In this case, the subscripts contributed by the lnamind appear
		as the first subscripts in the value of the resulting rlvn,
		separated by a comma from the (non-empty) list of subscripts
		appearing in the rest of the rlvn.

	with:
		If an rlvn was produced by an lnamind, then one of two
		situations exists.  In the first case, the name and possibly
		some subscripts are contributed by the rexpratom, and
		subsequent subscripts are contributed from the (non-empty)
		list of subscripts appearing as the rest of the lnamind.
		In the second case, the rexpratom evaluates to the empty
		string, and the name is provided by the first expr with
		any subscripts coming from the (possibly empty) subsequent
		list of exprs.
	
	With the exception of the definition of gnamind noted below, identical
	changes are made to 3.2.2.2, substituting gvn for lvn, rgvn for rlvn,
	and gnamind for lnamind.

	   gnamind ::= | @ rexpratom V gvn @ ( L expr )			       |
		       | @ rexpratom V "" @ ( expr V | ^ name | [ , L expr ] ) |

	Replace subparagraphs b and c of the proposed section 3.2.2.4 with:

	    b.	Each element is presented in its most canonic expr form,
		utilizing numints, strlits, the concatenate operator, and
		the $Char() function.  Let NV(x) be a function which produces
		the canonic representation of x.
	
	Delete the two-argument specification of $QName() from the proposed
	section 3.2.8.

	Replace the specification of $QSubscript() in its entirety with:

	    $QS[UBSCRIPT] ( glvn , intexpr )
		Let n be the number of subscripts associated with glvn, and
		m be the value of intexpr.  It is erroneous for m to be less
		than zero.  Let S0 represent the name level of glvn, and
		S1 - Sn respresent the first through nth subscripts, if any,
		of glvn.  In the following, the definition of NV(x) comes from
		section 3.2.2.4 .

			If m>n, the result is the empty string.

			Otherwise, the result is NV(Sm).

	    $QS[UBSCRIPT] ( glvn , intexpr1 , intexpr2 )
		Let s be the number of subscripts associated with glvn,
		m be the value of intexpr1, and n be the value of intexpr2.
		It is erroneous for m to be less than zero.  Let S0 represent
		the name level of the glvn, and S1 - Sn represent the first
		through nth subscripts, if any, of glvn.  In the following,
		the definition of NV(x) comes from section 3.2.2.4 .

			If m>s, the result is the empty string.
			If m>n, the result is the empty string.
			If m=n, the result is:
				( NV(Sm) )
			If n>s, the result is:
				( NV(Sm) , ... NV(Ss) )
			Otherwise, the result is:
				( NV(Sm) , ... NV(Sn) )
-- 
Hokey