Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!njin!princeton!phoenix!pucc.Princeton.EDU!wagner From: wagner@pucc.Princeton.EDU (John Wagner) Newsgroups: comp.lang.rexx Subject: Re: A Suggestion For Adding Function Pointers To REXX Message-ID: <13623@phoenix.Princeton.EDU> Date: 6 Feb 90 14:53:06 GMT References: <26534@cup.portal.com> <25545@cup.portal.com> <5344.25b20330@elroy.uh.edu> Sender: news@phoenix.Princeton.EDU Lines: 76 In article <26534@cup.portal.com>, Will@cup.portal.com (Will E Estes) writes: > (1) I dare anyone to write in REXX a general purpose binary sort > routine that acts on *any* REXX array and uses the PROCEDURE > keyword on the subroutine. > > (2) I dare anyone to write in REXX a general purpose binary sort > routine that acts on *any* REXX array without the PROCEDURE > keyword on the subroutine that doesn't look uglier than Bill the > Cat when he wakes up in the morning. > > The routine for (1) can't be written. And of course using the > PROCEDURE keyword is a must for anyone who wants to write > structured code. Will, This is simply not true. You may not like how the code looks, but that is different than saying it cannot be done. Remember that the SAA restriction on using "INTERPRET 'name: procedure expose' var" is an IBM restriction that is not part of the language. Don't use the IBM manuals for REXX when you are trying to understand what the language is supposed to be. The only source for that information is Colishaw's book "The REXX Language, A Practical Approach to Programming". > If you don't use the PROCEDURE keyword at all, then you can use > INTERPRET liberally throughout the subroutine to do just about > anything. But this is a totally unacceptable solution for any > number of reasons: 1) the code looks like hell; 2) it is not > efficient; 3) it is not supported in the compiler; 4) it requires > you to not use the PROCEDURE keyword which exposes all of the > caller's environment, and this is hack programming at its worst. I don't know what environment you are using REXX in, but I would guess that it is not VM/CMS since you seem to be missing the "feel" of it. This comes through in the way you state your dare. You have assumed that the correct answer is the ability to write all code in REXX. Colishaw never meant for that to be the case. REXX is a blend of high level code with system dependent function packages. You cannot separate the two. The appropriate response to your dare is that two forms come to mind. The first is: call sort 'Stem_to_sort.' , 'Stem.' < , 'Ascending' > < , 'Descending' > This places the sorted values found in 'Stem_to_sort.' into the stem 'Stem.' with 'Stem.0' containing the number of values. The third parameter just specifies the sort order. It uses the standard REXX technique of only making the first character significant so you could code 'DownDamnIt' it you wanted. The default would be ascending. This procedure would sort any value starting with 'Stem_to_sort.' so you might want to add another parameter to specify valid tail types (Any, Numeric, Character, etc.). It could also be used to sort some portion of a stem's values by specifying a partial tail, as in call sort 'Unsorted.Array.' , 'Sorted.array.' , 'D' If what you want to do is sort words in a string you use SortedString = sortwords(string <, 'Ascending' > ) <, 'Descending' > ) This one can be done using a REXX procedure, but is quicker in machine code. Function packages are meant to do exactly what their name implies, provide function not found in the base REXX language. They are meant as the way to make REXX extensible. You might want to take a look at a REXX function package available from Berthold Pasch (BITNET: PASCH@DHDIBM1 VNET: PASCH at GYSVMHD1). The package is known as XVAR (eXtended VARiable support) and is for REXX programs in CMS. It allows you to access copies of the variables in a callers routine (both R/O and R/W). Using this package it is possible