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

re: portability of .fas files



Since you mention with-keyboard as an example, let me suggest an alternative
implementation.
The original:
  (defmacro with-keyboard (&body body)
    #+(or ATARI DOS OS/2) ; *keyboard-input* existiert schon
      `(LET () (PROGN ,@body))
    #+UNIX
      `(UNWIND-PROTECT
         (PROGN
           (SYS::TERMINAL-RAW *TERMINAL-IO* T)
           ,@body
         )
         (SYS::TERMINAL-RAW *TERMINAL-IO* NIL)
       )
  )

my proposal:
  (defmacro with-keyboard (&body body)
    `(do-with-keyboard (function (lambda nil ,@body))))
  #+(or ATARI DOS OS/2)
  (defun do-with-keyboard (fn) (funcall fn))
  ; BTW, what was that LET () for?
  #+UNIX
  (defun do-with-keyboard (fn)
    (UNWIND-PROTECT
         (PROGN
           (SYS::TERMINAL-RAW *TERMINAL-IO* T)
           (funcall fn))
         (SYS::TERMINAL-RAW *TERMINAL-IO* NIL)))

The result is that the macro expands the same way on all machines.
The difference is hidden inside a function that differs from one
machine to the next.  Thus the compiled code that uses the macro
(as opposed to the compiled code that defines it, which is another
matter) is machine independent.

  > at least between DOS and UNIX machines.
  Why just these?
They're the ones that I actually use.  The point was really that
I did NOT only want compatibility between unix machines.  (This was
in response to an earlier message.)  Notice that my proposal was 
meant to obtain compatibility among ALL machines.