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

Re: load time conditional



    I've tried the following code in MACL 1.3.2 to achieve a 
    load time conditional defun. This code works fine with
    the source file, but not with the compiled 'FASL' file.
    Is there another possibility to achieve a load time
    conditionalisation? 
    
    ;File # foo
    (eval-when (load eval compile)
      #+bar
      (defun foo ()
        "www")
      
      #-bar
      (defun foo ()
        "qqqq")
      
      )
      
Simple.  The problem is that the definition of foo is controlled by
a READ-time conditional, #+bar.  bar was in *features* when you compiled
the file, so when the compiler called READ to get an expression to
compile, it saw (defun foo () "www").

If you want to use features at runtime, you could always write
(defun foo () (if (member 'bar *features* :test 'eq) "www" "qqq"))
but that's not what features are really intended for.