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

Questions about specification and possible implementations



I've been a bit busy, but since nobody else has popped up to answer your
questions, I'll take a crack at them.  I'll try to distinguish between
cases where I think the standard is clear and cases where there is
ambiguity and I am offering my own opinion as to how the ambiguity
should be resolved.

    ... some functions with all the &OPTIONAL and &KEY arguments may be
    difficult or inefficient to implement as true functions, and thus may
    be implemented as FEXPRs in the interpretor and MACROs in the
    compiler.

I don't see why you think that such a change would make things easier
or more efficient.

    The question is, what will (FUNCTION foo) do if foo is the
    name of a MACRO or FEXPR?

I think "it is an error" to call FUNCTION on a symbol with no
definition or whose definition is not a true function.  Some
implementations may just return whatever is in the SYMBOL-FUNCTION cell
without checking, but such a value cannot be used in APPLY.  It is not
possible, in general, to create a true function that does what the MACRO
or special form does.

    The book says the set of special forms is fixed and no way is provided
    to make new ones. But is any way provided to define some of the
    special forms from LISP level in the first place, or must all be
    handcoded in assembly language or C etc.? Is any way provided to
    install bugfixes in special forms by overlaying the old definition
    with a new one?

There is no way in Common Lisp to create new special forms.  It would
have been quite easy to define such a mechanism, but we deliberately
left such a mechanism out in the belief that having only a small, fixed
set of special forms makes it much easier to write various kinds of
program-manipulation tools.  It was also felt that macros are an
adequate substitute for new special forms.

If you are implementing a Common Lisp, you are free to think up any
internal mechanism you like for defining special forms at Lisp level.
In our Spice Lisp implemenation, we use a version of the old FEXPR
mechanism to define most of these things, but we do not make this
available at user level.

    At the front of the chapter on numbers it claims:
     (LET ((X Z) (Y Z))
       (EQ X Y))
    may be false if the value of Z is a number. I can't see a mechanism
    for this in any reasonable LISP unless Z is not only presently a
    number but has been declared a number and this is compiled code which
    represents the value of Z as a machine number instead of a LISP
    object, whereas X and Y are undeclared and thus LISP objects, so new
    objects must be constructed for X and Y to hold the value Z, and these
    new objects won't be EQ to each other. But could somebody who really
    knows tell me what the true explanation is?? The book leaves this a
    complete mystery.

I'm not able to parse that sentence (PDL overflow), but what we had in
mind was the case where Z is defined in a defconstant to be, say, a
number or a character.  In this case, we want it to be legal to
substitute that constant value for Z.  Now, if the object is immediate,
X and Y would be EQ, but if the object is consed you might end up with
X and Y pointing to distinct structures that are not EQ but that are EQL.

    In the introductory chapter, the Common-LISP book says semicolon
    causes all characters up to eol to be discarded, but doesn't say
    whether eol is kept or discarded.

All of these are answered quite clearly in the I/O chapter -- the
discussion in the intro was not meant to be definitive.  In this case,
the EOL is discarded.

    Ditto, doesn't say which characters inside "" are automatically
    letterified and which have their usual semantic effects and thus need
    explicit letterification to be treated as string text.

Only double-quote and the single-escape character (normally backslash)
need to be backslashed in a string.

    Ditto, backslash at end of line does what? (Illegal, quote just the
    next character which may be half of a crlf on some systems, quote the
    eol token always?)

Quotes the Newline character which is virtually there, regardless of the
system's usual conventions.  This is poor and confusing practice in most
situations, however.  Use #\newline.

    Ditto, vertical-bar, same questions as for "".

Only the single and multiple escape characters, normally vbar and
backslash, need to be quoted.

    When COPY-SYMBOL is done, the pnames will be the same, but will they
    be EQ or just EQUAL?

This is not clear in the manual.  In my opinion, this should be left up
to the implementor.  The new pname may or may not be EQ to the old one.

    The book doesn't say what (/ 1 0) does. Is it an error, or does it
    signal an error, or does it return the ratio of 1/0 as a way of
    representing infinity, or what?

Certainly it "is an error" in portable common Lisp.  I would expect
every implementation to signal an overflow or divide-by-zero error
unless it has actually implemented some sort of non-standard extension
to handle infinities and infinitesimals.

    If NIL is an element of an assoc list, does this element get skipped
    over by ASSOC et al or is it a stop flag?

Didn't you even try looking in the manual?  As it says on page 279, NIL
is allowed to be an element of an A-list and is simply passed over.

    How are the axis numbers of an array numbered, that is if you
    create an array by (MAKE-ARRAY 3 5 7) then will (ARRAY-DIMENSION array 0)
    return 3 or 7?

This is not stated, but seems obvious.  The numbering is left-to-right, 0
to whatever.  So in this case the answer is 3.

-- Scott