Path: utzoo!utgpu!water!watmath!clyde!att!ihnp4!ucbvax!LBL.GOV!LEICHTER%Venus.YCC.Yale.EDU%KL.SRI.COM%lbl%sfsu1.hepnet From: LEICHTER%Venus.YCC.Yale.EDU%KL.SRI.COM%lbl%sfsu1.hepnet@LBL.GOV Newsgroups: comp.os.vms Subject: Forcing expression evaluation in DCL Message-ID: <880529004903.23e038be@LBL.Gov> Date: 29 May 88 07:49:03 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 39 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)" 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