unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Alejandro Sanchez <hiphish@openmailbox.org>
Cc: guile-user@gnu.org
Subject: Re: Using '-1' in a method named '*'
Date: Tue, 28 Feb 2017 09:54:15 +0100	[thread overview]
Message-ID: <87r32ipufc.fsf@pobox.com> (raw)
In-Reply-To: <8760jvsan4.fsf@pobox.com> (Andy Wingo's message of "Mon, 27 Feb 2017 20:21:03 +0100")

On Mon 27 Feb 2017 20:21, Andy Wingo <wingo@pobox.com> writes:

> Hi,
>
> On Mon 27 Feb 2017 11:06, Alejandro Sanchez <hiphish@openmailbox.org> 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).

I spoke too soon.  Guile 2.1.x does indeed do this at compile-time, but
only if "v" is an instance of a built-in number type.  Guile 2.0.x
doesn't do this strength reduction at all at compile-time.

It turns out there is an easier way to reproduce this bug without GOOPS:

   (* -1 "")

scm_product was handling this case specially because of weird
implementation reasons (making sure that negating the most negative
fixnum was a bignum; see b5c40589).

In summary I think Guile's strength reduction is fine as it relies on
type inference to prove when it is safe.  This is "just" a bug, albeit
an annoying one that we need to fix!

Andy



  parent reply	other threads:[~2017-02-28  8:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-27 10:06 Using '-1' in a method named '*' Alejandro Sanchez
2017-02-27 19:21 ` Andy Wingo
2017-02-27 22:26   ` Alejandro Sanchez
2017-02-28  8:00   ` tomas
2017-02-28  8:54   ` Andy Wingo [this message]
2017-02-28  9:19     ` Andy Wingo
2017-02-28 14:24       ` Alejandro Sanchez
2017-02-28 17:53         ` Amirouche
2017-02-28 18:32           ` Ralf Mattes
2017-03-01 17:25         ` Andy Wingo
2017-03-01 23:46           ` Alejandro Sanchez
2017-03-02  0:18             ` Thomas Morley
  -- strict thread matches above, loose matches on Subject: below --
2017-03-03  0:07 Sandic, Aleksandar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r32ipufc.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=guile-user@gnu.org \
    --cc=hiphish@openmailbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).