[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

defun syntax / AutoLisp emu

 >Date: 25 Aug 1993 16:24:13 U
 >From: "Stephen Ervin" <Stephen_Ervin@venus.gsd.harvard.edu>
 >Subject: defun syntax / AutoLisp emu
 >To: "macl info" <info-mcl@cambridge.apple.com>
 >REGARDING                defun syntax / AutoLisp emulator 
 >dear lispers;
 >In an effort to create an MCL-based environment for programming graphics (not
 >graphical programming yet),  we're building an 'AutoLisp' emulator. (AutoLisp
 >is the lisp subset/variant built into AutoCad, from AutoDesk,  a popular CAD
 >system now fully fledged on macs)
 >A major annoyance/stumbling block is AutoLisp's idiosyncratic syntax for local
 >variable names;  instead of using 'let or '&aux in the lambda list,  they use
 >the syntax:
 >(defun  foo  (a b c / x y z) ...)
 >where the  /  is synonymous with &aux,  declaring x y z to be local vars.
 >Is there any hope of hacking defun so this would become acceptable to MCL? (In
 >the hopes of making complete transparency / portability between MCL and
 >AutoLisp code... It's hard enough to teach the semantics of scoping,  without
 >having syntax to screw it up! )
 >Any suggestions would be appreciated.    Thanks in advance,
 >Stephen M Ervin

You should probably define a macro to use instead of defun,
which does the substitutions you want, e.g.:

? (defmacro defun-auto (arglist &body body)
    `(defun ,(subst '&aux `/ arglist) ,@body))
? (macroexpand-1 '(defun-auto (a b c / x y z) body1 body2))
(defun (a b c &aux x y z) body1 body2)

You can of course call this macro DEFUN if you use it in a
package which doesn't use the COMMON-LISP package, and you manually
import just the functions you want to emulate AutoLisp.