Path: utzoo!attcan!uunet!husc6!mailrus!ames!ucsd!nosc!helios.ee.lbl.gov!h2opolo.ee.lbl.gov!mccanne From: mccanne@h2opolo.ee.lbl.gov (Steve McCanne) Newsgroups: comp.lang.postscript Subject: Re: An Idea to Help Make Postscript Easier to Read (and Write) Message-ID: <950@helios.ee.lbl.gov> Date: 7 Sep 88 06:00:22 GMT References: <940@helios.ee.lbl.gov> <5361@vdsvax.steinmetz.ge.com> Sender: usenet@helios.ee.lbl.gov Reply-To: mccanne@h2opolo.ee.lbl.gov (Steve McCanne) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 42 In article <5361@vdsvax.steinmetz.ge.com> barnett@vdsvax.steinmetz.ge.com (Bruce G. Barnett) writes: >In article <940@helios.ee.lbl.gov> forrest@ux1.lbl.gov (Jon Forrest) writes: > >I am trying to visualize a language that would let you call >a procedure that returns three values on a stack, then uses two of >them, does some other functions, and then uses the third. >When this is nested, the problem gets worse. Then add variable binding, and >delayed parsing of names. > Van's solution to multiple valued functions (in his PreScript language) was to get at individual return values via the dot operator. So, a function can be declared: "foo(x) returns (a, b, c)", and its values accessed via foo(x).a, etc. Also, "bar(foo(x))" is valid if bar takes three arguments. Or, you can say "a=foo(x)", where "a" is an array. >The values on the stack have no names, and the positions change They don't have names, but they do have relative offsets from the top of the stack. These values can be accessed via roll, exch, etc.--this turns out to be a good approach since stack manipulations are generally faster than the name to address resolution for named variables. >with every call. The function of the names could change dynamically. > This is a problem. PreScript simply disallows assignment to a function name; this makes perfect sense from a C standpoint. You can, however, assign a function's name to a variable. >I suppose you could convert a PostScript program to >pop all values off the stack, and assign names to each value. >Then all operations would be done with variables. > >But that program would be very inefficent. Yes, this is indeed inefficient. Keeping track of where things are on the stack, on the other hand, works pretty well. > Bruce G. Barnett > uunet!steinmetz!barnett Steven McCanne mccanne@helios.ee.lbl.gov