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

non-list arguments



    Date: Tue, 1 Apr 86 15:26 EST
    From: Robert Halstead <rhh at MIT-VAX.ARPA>

    To summarize, I think it should be permissible for

    	(eq? ((lambda x x) l) l)

    to return true, but it should not be a requirement.  Furthermore, it
    should be permissible for an implementation to report an error if l in
    the above expression is not a true list, but an implementation should
    not be required to do so.  Of course, it would still be true that

    	((lambda x x) 3 4 5)

    would return a freshly consed list, just like (list 3 4 5).  An
    interesting question:  do people expect (apply list l) to return a
    top-level copy of l?					-b.

Permitting sharing between the argument passed to apply and the
rest-argument leads to all kinds of obscure bugs - especially if sharing
isn't guaranteed.  In fact I have written and used interpreters which
shared the list, and I regretted it every time.  Efficiency shouldn't
guide the design on this issue.  A compiler could easily detect the
situation you described (a rest-variable referenced only as the last
argument to APPLY) and generate code which doesn't cons.

Jonathan