Subj : Re: Determining call context in SpiderMonkey To : netscape.public.mozilla.jseng From : InsipidL Date : Thu Aug 19 2004 02:50 pm I'm adding a scripting language to an existing bioinformatics software package. We basically have a series of arrays that hold floating point values. There are algorithmns that act upon those arrays that return other arrays. Most of the time only a single element of that array is needed by the user. But sometimes the user needs to stack these algorithmns one on top of each other. In order to simplify the language, we are avoiding any specific reference to object oriented programming, keeping the language much like a simple macro language. In the first case: i = a(param1, param2) We are returning our own JS class which encapsulates our array. It has implemented a custom Convert so that if a floating point value is requested, it just returned the last element of that array. This allows the user to simply print out the last value by doing: print(a(param1, param2)) but also apply these functions one on top of the other like in the 2nd example: b(a(param1, param2)) (where b is another function similar to a in that it acts upon our internal JS array wrapper and returns another class of the same). The script executes once per array element as new source numbers are generated as the machine runs. So if a user tries to store: i = a(param1, param2) That value will not be constant, as 'i' is an Object, which, when converted returns the last floating point value. As the script executes for each one this 'last' floating point value changes over time. I'd like: i = a(param1, param2) to return the floating point value at the time of execution, but also keep the syntax common so that the user can also do: b(a(param1, param2)) where we will return the Object itself. The alternative is to use: i = a(param1, param2) and define: b(aArray(param1, param2)) which I'm hoping to avoid to avoid cluttering the namespace. You mentioned that it is possible, can you point me to any keywords or flags that I should be searching for in the engine code to figure this out myself? Thanks! Brendan Eich wrote in message news:<412263EA.7060907@meer.net>... > john satoa wrote: > > > Is it possible given: > > > > i = a() > > > > and > > > > b(a()) > > > > To determine within the native a() handler, whether or not you are > > being called and assigned to a variable, or being called as a > > parameter to another function? If it is, is it possible to determine > > the name of the function that is using you as a parameter (ie "b") ? > > > > (yes it's a little weird, but will actually help our target users if I > > can determine this). > > > Currently in SpiderMonkey, for those two cases, you could dig out the > information you want. There's no public or "friend" API to help you, > though, so you'd be getting in bed with the engine. > > Can you say more about the use-case that you hope will be helped here? > > /be .