Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!alien.dec.com!postpischil From: postpischil@alien.dec.com (Always mount a scratch monkey.) Newsgroups: comp.sys.hp Subject: HP-28S program to manipulate programs Message-ID: <8902131556.AA26837@decwrl.dec.com> Date: 13 Feb 89 18:56:00 GMT Organization: Digital Equipment Corporation Lines: 31 Benoit Menendez asks for a way to create a program object which depends partially on an argument. In the code: << -> i << << -> x << x i + >> >> >> >> realize that << -> x << x i + >> >> is an object, and all that happens to this object when the program is evaluated is that it is placed on the stack. Since we want to create a program object not known at the time of writing, we cannot simply place a copy of an object on the stack. We therefore need a built-in function which returns a program object. I think the only suitable function is STR->, which takes a string and can return any object(s). So one possibility is: << "<< -> x << x " SWAP ->STR + " +" + STR-> >> This will perform the requested function, although it is not necessarily a good way to solve a problem. (Actually, there are some objects for which ->STR STR-> will not return the original object, such as strings with embedded quotes, and the above program will not work with such objects.) -- edp