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

FEATURE-CASE [was: porting scigraph to other platforms]



>Date: Thu, 19 Aug 1993 09:52:57 +0100
>From: Keunen Vincent <keunen@montefiore.ulg.ac.be>
>Subject: Re: porting scigraph to other platforms

>At 13:48 18/08/93 -0500, Kalman Reti wrote:
>>At 11:17 8/18/93 -0500, Sheldon S. Ball wrote:
>>>The next obstacle I have encountered in loading scigraph is in the file
>>>dwim:tv.lisp. The code below presents a problem. I am using clim-1.1 &
>>>MCL 2.0.
>>>;;;************** Code from tv.lisp ***********
>>>(defvar *default-server-path*
>>>    #FEATURE-CASE
>>>  (((and :clim-1.0 :genera) '(:sheet :screen (tv:console-default-superior)))
>>>   ((and :clim-1.0 :xlib (not :genera)) '(:clx))
>>>   (:clim-0.9 '(:clx))
>>>   (:clim-2 '(:motif))
>>>   ((not :clim) nil)))
>>>;;;*************** End code from tv.lisp **********

>>Well, #F isn't a defined dispatching macro character in Common Lisp.   Either
>>this code is
>>relying on some non-Common-Lisp feature of one or more Lisp implementations,
>>or it defines
>>this dispatching macro somewhere in itself but through some bug, it isn't
>>enabled in your
>>MCL environment at the time you try to load this file.
>>
>>You only have two options:  1) find source code for the #F reader macro and
>>the resulting
>>#FEATURE-CASE implementation and get it working or 2) recode the above as
>>separate
>>clauses each with their own #- and #+ clauses.
>Kalman is right about that.  To go further: once you have modified
>#FEATURE-CASE to use #+ and #-, you could use the code below to determine
>how to open a clim root window on different platforms (which seems to be
>what the *default-server-path* variable will be used for).

FEATURE-CASE is a reader macro which (as the name implies) implements a #+/#-
syntax in a CASE-like way.

The code can be found in the DWIM subsystem (under the SCIGRAPH directory),
which you should have if you're using SCIGRAPH.

DWIM is a set of macros that helps hide some of the messiness involved in
maintaining systems over several platforms.  As part of this we have found
FEATURE-CASE useful for the following reasons:

1] It supplies an implied "otherwise" clause.  In this case it compiles to
an error message that this form isn't supported by the specified
combinations of features.  (This clause can also be specified by the user
or ommitted entirely.)

2] It is somewhat easier to read (at least for some of us ;-) than a forest
of #+/#- forms.

As an example, for the case above

(defvar *default-server-path*
  #FEATURE-CASE
  (((and :clim-1.0 :genera) 
    '(:sheet :screen (tv:console-default-superior)))
   ((and :clim-1.0 :xlib (not :genera)) 
    '(:clx))
   (:clim-0.9 
    '(:clx))
   (:clim-2 
    '(:motif))
   ((not :clim) 
    nil))
   )

This is roughly the same as:

(defvar *default-server-path*
  #+(and :clim-1.0 :genera) '(:sheet :screen (tv:console-default-superior)))
  #+(and :clim-1.0 :xlib (not :genera)) '(:clx)
  #+clim-0.9 '(:clx)
  #+clim-2 '(:motif)
  #-clim nil
  #-(or (and :clim-1.0 :genera)
        (and :clim-1.0 :xlib (not :genera))
        :clim-0.9
        :clim-2
        (not clim))
    (error "Sorry, this portion of this program is currently
    supported only for the following:~{~%~S ~}"
           <LIST-OF-SUPPORTED-FEATURES>)
  )

Nichael