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

[no subject]

I think your fear of #+ and #- is not as irrational as you think.
I certainly share it and might as well lay out my reasons why...

#+ and #- were designed to handle the fact that various Lisp source files
wanted to be portable but in a way that would more or less free each Lisp
of knowing anything about the others. Hence, #+ and #- are designed to make
it truly invisible to programs in LispM lisp (for example) that Maclisp 
code was interleaved within it since that Maclisp code would be semantically
meaningless to any LispM program. Similarly, Maclisp didn't have to worry 
about LispM code. This was the best you could do without building into Maclisp
assumptions about how LispM was going to do things and vice versa.

Now, however, Common Lisp is trying to address portability in a different
way. It is trying to make semantics predictable from dialect to dialect.
As such, it can afford to use better mechanisms than #+ and #-.

The bad thing about #+ and #- is that they tie a tremendously useful piece
of functionality (site and feature conditionalization) to a syntax that
has no underlying structure in the language. One of the nice things that
people like about Lisp is the uniform underlying structure. There is no worry
as there would be in Algol, for example, about the x+y is a piece of syntax
which has to be treated differently than f(x,y) even though in Lisp they
share a common representation. #+ and #- are quite analagous to this, I
think, in that they are an irritating special case that is hard to carry
around internally. If you want to manipulate them, you have to create special
kinds of structures not provided in the initial language semantics. I am
worried about two things:

 * Programs that read these things. In the Programmer's Apprentice project,
   we have programs that want to read and analyze and recode functions.
   If the user has a program 
     (defun f (x) ( #+Maclisp + #-Maclisp - x 3))
   and the Apprentice reads his program on the LispM where it runs, it will
     (defun f (x) (- x 3))
   and later when it recodes it, it will have lost the #-Maclisp information.
   This is bad. I don't want to have to write my own reader to handle this.

 * Further, if I want to construct a program piece-wise in the apprentice and
   then print it out, I may want to site-conditionalize things. I don't want
   to have to have a special printer that prints out certain forms as #+x
   or #-x ... I want a form that is a structured part of the language and
   which the Lisp printer prints normally.

#+ and #- are not unique in causing this problem. #. and #, cause it, too.
However, their functionality is considerably harder to express with normal
syntax. #+ and #- have reasonably easy-to-contrive variants which work via
normal s-expressions... at least for most cases.

I won't even say #+ and #- should go away. I will, however, urge strongly
that no design decisions be made which would cause the user to want to use
#+ or #- to get a piece of functionality which can easily be gotten another
cleaner way.

The other point that I would like to make about #+ and #- while I am 
bad-mouthing them is that they are not structured. I have written code that
does things like 
  #+SFA X
    #+TOPS-20 W
    #-TOPS-20 (ERROR "# conditional failed")
and it really scares me that there's nothing to tell me that I'm not getting
2 forms in some environments or 0 in others where usually I want exactly 1.
How many times have you wanted #+ELSE ? Gee. I really wish there were 
the equivalent s-expression conditional so I could write
    (SFA X)
    (BIGNUM Z)
    (TOPS-20 W)
    (T (ERROR ...)))
or some such thing just to know I can see the structure of the expression I've
written. ... plus of course I'd have something my programs could read/print.
By the way, while this example is a contrived case, I've really seen
code much like it from time to time in the Macsyma sources. It's a real eyesore
to read.

Well, I guess that establishes my opinion on the situtation. I guess I think
#+ and #- had their place in history but the time for using them ought to pass
in Common Lisp since we can make real primitives with a clear portable meaning
to replace them.