> The question is why you are doing this. I'd rather not go into that. You have to study the middleware I'm porting from APL to relate to why I need a function which knows the name of its caller. And without the caller having to go to the trouble of telling it. The tool makes heavy use of two utility functions: "myname" and "mycaller", whose function should be obvious, even if their application isn't. And please don't ask why a function might conceivably need to discover its own name: the requirement has been known to arise.
In APL the solution is easy: the stack is always available for a function to inspect while it's running. In J you have to switch the suspension stack on. Is this because the facility is quirky and inefficient, or simply because a lot of people don't need it or want it -- as I don't, as a rule? "mycaller", implemented the APL way, is working fine (touch-wood). But if there's a slick J technique without enabling the suspension stack then it would simplify the code considerably and I can lose a few heavily-looping saddle-functions. 2011/1/25 Björn Helgason <[email protected]>: > The question is why you are doing this. > > If it is because of development or something you want for when the system is > running. > > You can of course make sure the caller sends its name in as part of > arguments passed. > > During development I usually pepper smoutput all over the code. > > For a running application I usually write out stuff in logfiles and/or use > wdstatus to see if everything is running ok. > > > 2011/1/25 Ian Clark <[email protected]> > >> If I define two or more verbs tacitly like this: >> >> act1 =: action >> act2 =: action >> ... >> >> how, inside the verb: action, can I identify the calling verb -- >> ideally as the literal name, eg 'act1'? >> >> I can solve the problem ... >> >> (a) by having the caller pass its own name as an argument in a rather >> more complex tacit expression, eg >> >> act1 =: action bind 'act1' >> act2 =: action bind 'act2' >> ... >> >> (b) by enabling suspension with: (13!:0)1 (in the caller of act1, >> act2) and then inspecting the stack within action by means of 0{"1 >> (13!:13 '') >> ...which is what I'm using at present. >> >> (a) is not out of the question, but complicates the code, especially >> generated code. >> And I don't like (b) -- besides being clumsy I anticipate gotchas in >> the long term. >> >> Am I right to feel edgy about (b), for general application? >> >> Is there a neater way? >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > > -- > Björn Helgason, Verkfræðingur > Fornustekkum II > 781 Hornafirði, > t-póst: [email protected] > gsm: +3546985532 > sími: +3544781286 > http://groups.google.com/group/J-Programming > > > Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans > > góður kennari getur stigið á tær án þess að glansinn fari af skónum > /|_ .-----------------------------------. > ,' .\ / | Með léttri lund verður | > ,--' _,' | Dagurinn í dag | > / / | Enn betri en gærdagurinn | > ( -. | `-----------------------------------' > | ) | (\_ _/) > (`-. '--.) (='.'=) ♖♘♗♕♔♙ > `. )----' (")_(") ☃☠ > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
