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

Issue: LAMBDA-FORM (Version 1)



Issue:        LAMBDA-FORM
References:   LAMBDA (p59)
Category:     ADDITION
Edit history: 22-Jun-88, Version 1 by Pitman
Status:	      For Internal Discussion

Problem Description:

  In Scheme, one writes not #'(LAMBDA ...) but just (LAMBDA ...).

  Many Common Lisp programmers have asked for this feature.
  It can be written by the user, but since it's a commonly asked
  for feature, it would make sense for it to be in the standard.

  Also, even though the definition is trivial,

    (DEFMACRO LAMBDA (BVL &REST BODY) `#'(LAMBDA ,BVL ,@BODY))

  it is difficult to offer this as an extension because then "portable
  code" tries to define it, it will get a redefinition warning because
  it will be clobbering the system's predefined definition.
  [An implementation could shadow LAMBDA, but that, too, has associated
  problems.]

Proposal (LAMBDA-FORM:NEW-MACRO):

  Add a LAMBDA macro, which has equivalent effect to:

    (DEFMACRO LAMBDA (BVL &REST BODY) `#'(LAMBDA ,BVL ,@BODY))

  Rationale:

   This is an upward-compatible extension which ``codifies current
   practice'' in that it makes a commonly defined macro available
   as a standard part of the language.

Proposal (LAMBDA-FORM:NEW-SPECIAL-FORM): 

  Add a new special form LAMBDA, which has equivalent effect to:

    (DEFMACRO LAMBDA (BVL &REST BODY) `#'(LAMBDA ,BVL ,@BODY))

  except that the macro expansion might not be available in all
  implementations.

  Rationale:

   This is a slightly incompatible extension which ``codifies current
   practice'' in that it makes a commonly defined feature available
   as a standard part of the language. The idea of making it a special
   form would be that some people would prefer to treat (LAMBDA ...)
   as more primitive than #'(LAMBDA ...).

Test Case:

  #1: (DEFUN ADDER (N) (LAMBDA (X) (+ X N)))
      (FUNCALL (ADDER 5) 3) => 8
  
  #2: (MAPCAR (LAMBDA (X) (+ X 3)) '(1 2 3)) => (4 5 6)

  #3: (MACROEXPAND '(LAMBDA (X) (+ X Y)))
      ; The following result is required under NEW-MACRO
      ;  and is possible under NEW-SPECIAL-FORM
      => (FUNCTION (LAMBDA (X) (+ X Y)))
      ; The following result is prohibited under NEW-MACRO
      ;  and is permitted but not required under NEW-SPECIAL-FORM.
      => (LAMBDA (X) (+ X Y))

Current Practice:

  Symbolics Genera implements NEW-MACRO.

  Symbolics Cloe does not offer a LAMBDA macro because users who defined
  their own in portable code complained that they were getting redefinition
  warnings that CLtL had led them to believe shouldn't happen. (Actually,
  CLtL technically does allow it, but arguably only by technicality.)

Cost to Implementors:

  NEW-MACRO is trivial to add.

  NEW-SPECIAL form might require more work in some implementations, but
   probably not a lot more.

Cost to Users:

  None. This change is basically upward compatible.

Cost of Non-Adoption:

  There are no really major consequences of non-adoption.

Benefits:

  Improved aesthetics.

  It's been suggested that some people write '(LAMBDA ...) rather than
  #'(LAMBDA ...) because it's less ugly, and then run into confusion
  later. If they could just write (LAMBDA ...), some that use overly
  superficial reasons for the choice of one notation over another might
  accidentally select the primitive they should probably really be using.

Aesthetics:

  Some people believe strongly that (LAMBDA ...) looks a lot better
  than #'(LAMBDA ...). Certainly it takes up fewer characters, and
  (LAMBDA ...) is a notable offender in code needing to be split onto
  multiple lines, so every little bit helps.

Discussion:

  Numerous people have suggested this from time to time in the past,
  but it's often been amidst a bunch of other more controversial issues.
  Pitman wrote up this proposal and supports LAMBDA-FORM:NEW-MACRO.