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

Re: variata



>Date: Wed, 23 Apr 86 23:13:58 EST
>From: Jonathan A Rees <JAR%mc.lcs.mit.edu@CSNET-RELAY.ARPA>
>Subject:  variata

I'm in general agreement with JAR's proposals, but...

>  - (ELSE) isn't a legal clause.  [If it is, what does it return, and why?]
>  - (COND) and (CASE x) are syntactically legal expressions.  [No one
>    objected to this liberalization when I raised the question before.]

What is the difference between (COND (ELSE)) and (COND)?  Why is one
wrong but the other OK?  

>  - (BEGIN) and (LAMBDA (X)) are not necessarily syntactically legal.
>    [Several people objected to this extension.]

What is the difference between (BEGIN) and (COND)?  Why is one wrong
but the other OK?

>  - It's not specified what happens if the constants in a CASE are
>    objects other than numbers, symbols, characters, or booleans.
>    [This allows implementations to decide for themselves what
>    happens in other situations - EQV?, EQUAL?, etc.]

I think CASE should continue to be defined in terms of EQV?.  This is
consistent with Common LISP's CASE, which is defined in terms of EQL.
There's also the issue of program-generated programs, which could
conceivably have weird CASE keys (like closure objects) that are known
to be EQ? or EQV? to other constants in the same procedure.  It's
bizarre, but I'd like to know what to expect.

>  - EQ? and EQV? must both return true if their arguments are both
>    empty strings or both empty vectors. [...]

What about those of us contemplating extending Scheme to include other
compound types?  What happens with the following?

	(EQ? (MAKE-VECTOR 0) (MAKE-ARRAY '(0)))
	(EQ? (MAKE-VECTOR 0) (MAKE-ARRAY '(0 0)))
	(EQ? (MAKE-ARRAY '(0 0)) (MAKE-ARRAY '(0 0)))
and my favorite,
	(EQ? (MAKE-VECTOR 0 3) (MAKE-VECTOR 0 4))

By the way, is (MAKE-VECTOR 0 <exp>) valid?  Is it reasonable to issue
a warning message?

What if an implementation of Scheme extends it with adjustable arrays,
as in Common LISP?

	(LET ((X (MAKE-ARRAY '(0) :ADJUSTABLE 'T)))
	  (EQ? X (MAKE-ARRAY '(0))))

[I'm not advocating Common LISP's messy syntax, just using it for clarity.]

Common LISP says that strings are the same as simple vectors with
elements of type STRING-CHAR.  Is the empty string "" EQV? to a
non-simple vector with elements of type STRING-CHAR?  These questions
are particularly pertinent for those of implementing both Scheme and
Common LISP in the same name space (or one on top of the other).

>The RRRS says nothing at all about whether the result of APPEND sharing
>structure with its arguments.  Common Lisp says explicitly that all
>arguments but the last are copied, and the last one never is.  I think
>this is wrong, and maybe incompatible with existing implementations.  T
>permits sharing (not clobbering) whenever that makes sense, e.g.
>      (let ((x (list 1 2)))
>	(eq? x (cdr (append '(a) x '() '()))))
>might be true.  Is it OK if I make this explicitly OK?

I'd like some discussion on this.  It sounds like something a LISP
programmer could trip up on, especially those who use (APPEND X '())
to copy X.  Steele's book specifically mentions that APPEND will work
that way in Common LISP, but implies that it is poor style.  My
inclination is to be compatible with Common LISP in order to minimize
frustration for the poor people we're trying to win over to Scheme.

>What about (let ((x (list 'a))) (eq? x (reverse x))) ?

I feel strongly that REVERSE should always copy (unless its argument
is the empty list), since it is easier to remember that rule than that
it does so only when there's more than one element in the list.
Pragmatically, I often do something like (APPEND! (REVERSE X) Y), and
wouldn't want to side effect the original list in X if it had exactly
one element.  (Note that this works correctly when X is the empty
list, so this is a pretty unusual boundary condition.)

Regards,
David Bartley
-------