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


I wrote the following "straw man" proposal mostly because I'm tired of
seeing the incessant mail on Common-Lisp about this topic and I'm hoping
we can quickly work toward having something to push back at the
Common-Lisp community to appease them on this obviously important issue.
I expect that this will go through a few iterations before the form and
content settle down, but I just wanted to get something concrete (straw?)
on our table...
References:   5.2.2 Lambda Expressions (pp59-66)
Category:     ADDITION
Edit history: 10-Apr-88, Version 1 by Pitman
Status:	      For Internal Discussion

Problem Description:

  Currently, all lists created for use with the &REST syntax in lambda lists
  have indefinite extent. Many users have complained that this is not always
  necessary and often creates unnecessary garbage.


  Introduce a DYNAMIC-EXTENT declaration such that
  would permit the implementation to make the list held by the indicated
  VARIABLE to have only dynamic extent.

  Example:	(DEFUN FOO (&REST L)
		  (APPLY #'BAR L))


    This would allow the programmer to declare general information about
    data flow which it might be difficult or impossible for a compiler to
    obtain mechanically.


  Introduce a DYNAMIC-EXTENT declaration such that
  would permit the implementation to make the list held by the rest argument
  to the immediately containing binding form have only dynamic extent. It would
  be an error if the immediately containing binding form did not have an
  &REST specifier to which this declaration could apply.

  Example:	(DEFUN FOO (&REST L)
		  (APPLY #'BAR L))


    This would allow the programmer to declare specific information about
    rest argument data flow which it might be difficult or impossible for
    a compiler to obtain mechanically, but would not attempt to treat the
    more general issue of how this related to other kinds of data flow.

Current Practice:

  Lucid implements REST-ARGUMENT-EXTENT:GENERAL [at least for rest arguments;
  I don't know if they attach a meaning to its use for any other arguments. -kmp]


Cost to Implementors:

  Since implementations are only allowed (and not required) to make any use
  of this declaration, there is no forced cost. In practice, though, some
  users will probably get irritated if implementations fail to do something
  useful with this declaration, so some implementors may end up having to pay
  even if they don't technically have to.

  Fully implementing even dynamic rest lists (let alone dynamic objects of
  all kinds or for other data flow paths, whatever that may mean) may not be
  a small change in some implementations. There is possible interaction with
  garbage collection, possible implications on hidden assumptions in code
  generation for stack winding and unwinding, TYPEP, etc. depending on how the
  details of how dynamic lists end up being implemented.

Cost to Users:

  None. This is an upward-compatible change for users.

  Many users are already exploiting this feature in an implementation-dependent
  way, so this change will improve the maintainability of code for those
  implementations and may encourage some new implementations to offer equivalent

Cost of Non-Adoption:

  Some users will continue to be discouraged with implementations that do
  "gratuitous heap consing" of rest lists.


  Many implementors claim that large improvements in the performance of programs
  (and their associated garbage collection) are to be had from adopting some form
  of proposal such as this.


  Debugging program errors involving dynamic extent objects can be very tricky.
  This feature should be strongly discouraged for naive programmers.


  The example above is perhaps not the best example because APPLY is something
  the compiler can have primitive knowledge about, and good compilers may in fact
  already optimize this case even without the need for a user declaration.
  Nevertheless, if the function were MY-APPLY rather than APPLY, the case would
  be made because (non-block) compilers cannot make assumptions about what
  MY-APPLY would do without violating the normal rules for modular compilation.

  KMP supports REST-ARGUMENT-EXTENT:CONSERVATIVE pending discussion of why