Mark H Weaver <m...@netris.org> writes:

> David Kastrup <d...@gnu.org> writes:
>>
>> A list in dotted tail position is evaluated via (map ... eval) rather
>> than (eval ...).  I don't see much of a problem with that.
>
> No, it's worse than that.  I think you failed to understand my point,
> so let me try again.  You propose that (f . x) should be equivalent to
> (apply f x).

When x is not a pair or ().

> Therefore, (f . (g x y)) should also be equivalent to (apply f (g x
> y)).

But (g x y) is a pair.

> To make this more concrete, suppose 'f' is 'vector and 'g' is 'list':
>
>   (vector . (list 1 2))

(list 1 2) is a pair (with the car list and the cdr (1 2)).

> If we were to adopt your proposal, users would naturally expect this to
> evaluate to #(1 2).  However, the evaluator sees (vector list 1 2) and
> thus produces a vector of three elements: #(#<procedure list _> 1 2).

Sure.

> In summary, your proposed syntax could only be detected if the dotted
> tail happened to be an atom.

() is an atom, but it is already treated differently.

> Scheme has a very useful property which your proposed syntax would
> destroy: any valid expression can be substituted for any other valid
> expression, and the result has the same meaning except for the
> substitution.

guile> (display . (close (current-output-port)))
#<primitive-procedure close>guile> 

Now try

(define x (close (current-output-port)))
(display . x)

Good luck.  The context already decides what a valid expression is.  Not
everything looking like one is treated like one.

-- 
David Kastrup

Reply via email to