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

Trying to implement FPOSITION with LAMBDA-MACROs.



    Date: Friday, 29 January 1982  19:46-EST
    From: Richard M. Stallman <RMS at MIT-AI>
    To:   HIC at MIT-AI, common-lisp at SU-AI
    Re:   Trying to implement FPOSITION with LAMBDA-MACROs.

    LAMBDA-MACRO is a good hack but is not exactly what JONL was suggesting.
Yes, I know.  I think it's the right thing, however.

    The idea of FPOSITION is that ((FPOSITION X Y) MORE ARGS)
    expands into (FPOSITION-INTERNAL X Y MORE ARGS), and
    ((FPOSITION) MORE ARGS) into (FPOSITION-INTERNAL NIL NIL MORE ARGS).
    In JONL's suggestion, the expander for FPOSITION operates on the
    entire form in which the call to the FPOSITION-list appears, not
    just to the FPOSITION-list.  This allows FPOSITION to be handled
    straightforwardly; but also causes trouble with (FUNCTION (FPOSITION
    ...)) where lambda-macros automatically work properly.
Yes, that's right.  If you don't care about #'(FPOSITION ..), then you can have
the lambda macro expand into a real macro which can see the form, so you
can use lambda macros to simulate JONL's behavior quite easily.

    It is possible to define FPOSITION using lambda-macros by making
    (FPOSITION X Y) expand into
    (LAMBDA (&REST ARGS) (FUNCALL* 'FPOSITION-INTERNAL X Y ARGS))
    but this does make worse code when used in an internal lambda.
    It would also be possible to use an analogous SUBST function
    but first SUBST functions have to be made to work with &REST args.
    I think I can do this, but are SUBST functions in Common Lisp?
Yes, this is what I had in mind.  The fact that this makes worse code
whe used as an internal lambda is a bug in the compiler, not an
intrinisic fact of Common-Lisp or of the Lisp Machine.  However, it would
be ok if subst's worked with &REST args too.