[comp.os.vms] Forcing expression evaluation in DCL

LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (05/26/88)

In a recent message, I said that DCL provided a syntax for specifying SYMBOL
SUBSTITUTION anywhere (the apostrophe), but no mechanism for specifying
GENERAL EXPRESSION EVALUATION.

After thinking about it a bit more, I realized that this is false:  Since
symbol substitution includes evaluation of lexicals, and evaluation of
lexicals can cause general expression evaluation, you can get the effect by
using the F$STRING() lexical in an unexpected way.  Thus, suppose X1 and X2
contain integers and, for whatever reason, you want to create a file whose
name is the sum of the two integers.  The direct approach is:

	$ X = X1 + X2
	$ CREATE 'X'

The DCL hacker's approach is:

	$ CREATE 'F$STRING(X1 + X2)'

You can use any expression you like as an argument to F$STRING.  If you want
an integer, rather than a string, result, you can use F$INTEGER instead.  I
can't see any way to make this polymorphic (i.e., get back a string or integer
depending on what the expression evaluated to), but I also can't think of
any reason why you'd want to do that.

Of course, this works for quoted strings, too:

	$ SEARCH/EXACT FILE.TXT "The number is ''F$STRING(X1 + X2)'"

							-- Jerry

LEICHTER%Venus.YCC.Yale.EDU%KL.SRI.COM%lbl%sfsu1.hepnet@LBL.GOV (05/29/88)

Received: from KL.SRI.COM by LBL.Gov with INTERNET ;
          Sat, 28 May 88 21:05:39 PDT
Received: from Venus.YCC.Yale.Edu by KL.SRI.COM with TCP; Thu 26 May 88 06:16:54-PDT
Date: Thu, 26 May 88 09:05 EST
From: "Jerry Leichter (LEICHTER-JERRY@CS.YALE.EDU)"
 <LEICHTER@Venus.YCC.Yale.Edu>
Subject: Forcing expression evaluation in DCL
To: INFO-VAX@KL.SRI.COM
X-VMS-To: INFOVAX
 
In a recent message, I said that DCL provided a syntax for specifying SYMBOL
SUBSTITUTION anywhere (the apostrophe), but no mechanism for specifying
GENERAL EXPRESSION EVALUATION.
 
After thinking about it a bit more, I realized that this is false:  Since
symbol substitution includes evaluation of lexicals, and evaluation of
lexicals can cause general expression evaluation, you can get the effect by
using the F$STRING() lexical in an unexpected way.  Thus, suppose X1 and X2
contain integers and, for whatever reason, you want to create a file whose
name is the sum of the two integers.  The direct approach is:
 
	$ X = X1 + X2
	$ CREATE 'X'
 
The DCL hacker's approach is:
 
	$ CREATE 'F$STRING(X1 + X2)'
 
You can use any expression you like as an argument to F$STRING.  If you want
an integer, rather than a string, result, you can use F$INTEGER instead.  I
can't see any way to make this polymorphic (i.e., get back a string or integer
depending on what the expression evaluated to), but I also can't think of
any reason why you'd want to do that.
 
Of course, this works for quoted strings, too:
 
	$ SEARCH/EXACT FILE.TXT "The number is ''F$STRING(X1 + X2)'"
 
							-- Jerry