guile-devel
[Top][All Lists]
Advanced

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

Re: Dotted pair call argument


From: David Kastrup
Subject: Re: Dotted pair call argument
Date: Tue, 21 Feb 2012 19:05:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Mark H Weaver <address@hidden> writes:

> David Kastrup <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]