michaelm@bcsaic.UUCP (michael maxwell) (05/30/86)
This is on Franz Lisp (v38.91) under BSD 4.2 on a Sun II... (1) I would like to set a control character to do a (return) from a break level, using 'setsyntax.' It doesn't work; Lisp says No prog to return from (Nor can a function called from the break level itself call (return)--same error msg.) Likewise, you can't set a control character to do a (retbrk) from a break level with 'setsyntax'; the error message in this case is: apply: Undefined Function retbrk However, you can set a control character to do a (reset). Short of creating my own break loop, is there another way I can get a control character to do a return? i.e. to continue the function in which break was called, not reset to the top level... (2) Some characters seem to be impossible to reset as vmacros using 'setsyntax.' I can understand why you can't reset ^Y, etc., but why not ^R? According to 'getsyntax', the syntax of ^R has been reset, but the reader seems to ignore it. (3) Assuming a character's syntax has been reset as a "vmacro," how can you find out exactly what function the character has been set to (short of typing it and observing what Lisp does)? Is there a way for a program to find out? (4) Finally, has anyone had any luck in changing the readtable in compiled code? (I think I've asked this before, w/o luck.) -- Mike Maxwell Boeing Artificial Intelligence Center ...uw-beaver!uw-june!bcsaic!michaelm
ags@pucc-h (Dave Seaman) (06/02/86)
In article <555@bcsaic.UUCP> michaelm@bcsaic.UUCP (michael maxwell) writes: >This is on Franz Lisp (v38.91) under BSD 4.2 on a Sun II... > >(1) I would like to set a control character to do a (return) from a break >level, using 'setsyntax.' It doesn't work; Lisp says > No prog to return from This is not a 'setsyntax' problem. It's just that the (return) must appear (lexically) within a prog. I don't know any way around this. >(2) Some characters seem to be impossible to reset as vmacros using >'setsyntax.' I can understand why you can't reset ^Y, etc., but why not ^R? >According to 'getsyntax', the syntax of ^R has been reset, but the reader >seems to ignore it. I believe any character can be reset. For ^Y you might have to use (ascii 25), but it should work. On the other hand, any keyboard character that is intercepted before it is seen by Franz will continue to have its special meaning in the shell. >(3) Assuming a character's syntax has been reset as a "vmacro," how can you >find out exactly what function the character has been set to (short of typing >it and observing what Lisp does)? Is there a way for a program to find out? I don't know of a built-in way to find this, but it wouldn't be hard to use property lists to keep track of the information if it is actually needed. >(4) Finally, has anyone had any luck in changing the readtable in compiled >code? (I think I've asked this before, w/o luck.) Yes, I have done this. There is no problem if readtable is declared special. -- Dave Seaman pur-ee!pucc-h!ags "You would think the President would spend his time worrying about Russia or China. He hasn't slept in eight nights, worrying about Libya!" - James Coburn in "The President's Analyst" (1967)
colonel@ellie.UUCP (Col. G. L. Sicherman) (06/05/86)
> (2) Some characters seem to be impossible to reset as vmacros using > 'setsyntax.' I can understand why you can't reset ^Y, etc., but why not ^R? > According to 'getsyntax', the syntax of ^R has been reset, but the reader > seems to ignore it. That's the UNIX tty driver. You need to issue a "stty" to the shell if you want to reset ^R. Normally Franz never sees your ^R. > (3) Assuming a character's syntax has been reset as a "vmacro," how can you > find out exactly what function the character has been set to (short of typing > it and observing what Lisp does)? Is there a way for a program to find out? I've done it, but I've forgotten how. You may need to consult the oblist. -- Col. G. L. Sicherman UU: ...{rocksvax|decvax}!sunybcs!colonel CS: colonel@buffalo-cs BI: csdsicher@sunyabva
max@ecrcvax.UUCP (Max Hailperin) (06/05/86)
The reason why you have no luck setting the syntax for ^R is that ^R is by default interpreted by the terminal driver as reprint line. This can be changed with stty if you really want ^R. The fact that (return) must be lexically within the prog isn't the whole truth. Were it, then typing (return) at a break-loop wouldn't work either. The real truth is that the break-loop specifically checks for forms whose car is return and handles them specially. (The code is in /usr/lib/lisp/toplevel.l) Thus one obvious approach is to extend this special case code. A better way is to have the character-macro return a (return) form, not execute it. For example: (defun return-character-macro (x) (if (null x) (tconc nil '(return)) (tconc x '||))) ; that's a ctrl-P if you can't see it (add-syntax-class 'vfirst-infix-macro '(cinfix-macro escape-when-first)) (setsyntax '|| 'vfirst-infix-macro 'return-character-macro) ;likewise together with telling the shell stty brk ^P results in ctrl-P (without needing a return following it) returning from a break loop. This assumes you are using the new terminal driver, but nearly anyone does.
albert@kim.Berkeley.EDU (Anthony Albert) (06/14/86)
In article <1126@ellie.UUCP> colonel@ellie.UUCP (Col. G. L. Sicherman) writes: >> (3) Assuming a character's syntax has been reset as a "vmacro," how can you >> find out exactly what function the character has been set to (short of typing >> it and observing what Lisp does)? Is there a way for a program to find out? > >I've done it, but I've forgotten how. You may need to consult the oblist. >-- >Col. G. L. Sicherman You can use getsyntax (e.g. (getsyntax '\X)) to find out what class the character is in. If it is in a "macro" class (e.g. vmacro, vsplicing-macro), the value of the function it is set to is assigned to the property which is the value of "readtable". Therefore, to get the name of the function, you can use (get '\X readtable). Of course, if the function has been compiled, you still won't know what it does. Anthony Albert ..!ucbvax!kim!albert albert@kim.Berkeley.EDU
albert@kim.Berkeley.EDU (Anthony Albert) (06/14/86)
In article <14352@ucbvax.BERKELEY.EDU> albert@kim.Berkeley.EDU.UUCP (Anthony Albert) writes: >In article <1126@ellie.UUCP> colonel@ellie.UUCP (Col. G. L. Sicherman) writes: >>> (3) Assuming a character's syntax has been reset as a "vmacro," how can you >>> find out exactly what function the character has been set to (short of typing >>> it and observing what Lisp does)? Is there a way for a program to find out? >> >>I've done it, but I've forgotten how. You may need to consult the oblist. >>-- >>Col. G. L. Sicherman > >You can use getsyntax (e.g. (getsyntax '\X)) to find out what class the ^ >character is in. If it is in a "macro" class (e.g. vmacro, vsplicing-macro), >the value of the function it is set to is assigned to the property which >is the value of "readtable". Therefore, to get the name of the function, you >can use (get '\X readtable). Of course, if the function has been compiled, ^ >you still won't know what it does. In my previous posting I should have explained that "X" is the character whose syntax is being investigated. Anthony Albert ..!ucbvax!kim!albert albert@kim.Berkeley.EDU