guile-user
[Top][All Lists]
Advanced

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

Re: Using '-1' in a method named '*'


From: Andy Wingo
Subject: Re: Using '-1' in a method named '*'
Date: Mon, 27 Feb 2017 20:21:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hi,

On Mon 27 Feb 2017 11:06, Alejandro Sanchez <address@hidden> writes:

> (define v (make <vector3> #:x 1))
>
> (* -1 v)  ; Does not work
> (* -2 v)  ; Works fine

I believe that Guile is doing strength reduction, transforming (* -1 v)
to (- 0 v).

It could be that this is totally the wrong thing.  Is (* x 2) -> (+ x x)
a valid transformation if you don't know the type of x?  I don't know.

I think there's currently an assumption that if you extend *, that you
will do so in a mathy way, and that you implement - + and similar.  But
in this case it's not the clear right thing to do.

WDYT?  We could remove this transformation, or only apply it when type
inference has run.

Andy



reply via email to

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