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

Uses of SET



I am a unashamed (albeit sparing) user of SET in Lisp.  The majority of
uses are in functions which define, redefine or embed (? our local term
for redefining a function in terms of it's previous definition) functions.
(Note that our dialect of Lisp does NOT have function-value cells and
assignment is used for function definition.)  These function (NOT macros)
accept lists of names (identifiers) and definitions, process the definitions
in various ways, then use SET to install the result.  This assignment
is expected to modify the dynamic environment, not the global environment(s)
exclusively.

A second use of set is possibly more interesting.  I have a function which
accepts an a-list of properties and uses it to initialize a collection
of dynamic variables.  The a-list contains only those name/value pairs
which are to differ from various defaults.  The code used is:

(Note that we use a-list format for property lists, not flat lists, hence
GET works on a-lists.)

(MAPC
  (LAMBDA (PROP VAR DEFLT)
    (SET VAR
      (COND
        ( (GET OPTIONLIST PROP) )
        ( 'T
          DEFLT ) )) )
  '(:MACRO-APP-SD :OP-RECOGNITION-SD :MESSAGE :LISTING :FILE :NOLINK
     :SOURCELIST :TRANSLIST :LAPLIST :BPILIST :NOMERGE :OPTIMIZE
     :LISPLIB-ACTION-CLASS :NOSTOP :QUIET :SILENT :DELAY-COMPILATION)
  '(MACRO-APP-SD OP-RECOGNITION-SD MESSAGESTREAM LISTSTREAM FILESTREAM NOLINK
     SOURCELIST TRANSLIST LAPLIST BPILIST NOMERGE OPTIMIZE MEMBERCLASS NOSTOP
     QUIET SILENT DELAY-COMPILATION)
  (LIST S,MACRO-APP-SD S,OP-RECOGNITION-SD CUROUTSTREAM CUROUTSTREAM
    () () () () () () () 4 0 () () () ()))

Since this is not a common operation it was felt that the simplicity of
maintaining parallel lists of property-names/variables/default values
was better than writing out seventeen (currently) SETQs with conditional
arguments and calls to GET.

Subject: new question; macro definitions

I am a new user of PCScheme (sp?), and have just ciphered out the way
macros are hidden.  I find it odd that macros have only global definitions,
i.e. on property lists.  This seems most un-Scheme-like.  In our Lisp we
use a distinguished form (MLAMBDA ...) for macro definitions, and use the
same definition methods as we use for functions.  Of course this leads to
other complexities and confusions.  Could anyone direct me to commentary
on the relative merits of various macro definition schemes (pun intended)?

Thank you,
     Cyril N. Alberga