unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: David Pirotte <david@altosw.be>
Cc: bug-guile@gnu.org
Subject: Re: vm-error: guile-gnome-2 / treeview / 'button-press-event
Date: Thu, 14 Jul 2011 11:07:10 +0200	[thread overview]
Message-ID: <87r55tkz7l.fsf@pobox.com> (raw)
In-Reply-To: <20110709035114.31446e40@rascar> (David Pirotte's message of "Sat, 9 Jul 2011 03:51:14 -0300")

Hi David,

On Sat 09 Jul 2011 08:51, David Pirotte <david@altosw.be> writes:

> Too few values returned to continuation

> 		    (let* ([...]
>                          (path-values ;; (get-path-at-pos w x-pos y-pos)
> 			    (values (list 1) #t 10 10)
> 			    ))

The problem is here.  From the NEWS:

    ** Returning multiple values to compiled code will silently truncate the
       values to the expected number

    For example, the interpreter would raise an error evaluating the form,
    `(+ (values 1 2) (values 3 4))', because it would see the operands as
    being two compound "values" objects, to which `+' does not apply.

    The compiler, on the other hand, receives multiple values on the stack,
    not as a compound object. Given that it must check the number of values
    anyway, if too many values are provided for a continuation, it chooses
    to truncate those values, effectively evaluating `(+ 1 3)' instead.

    The idea is that the semantics that the compiler implements is more
    intuitive, and the use of the interpreter will fade out with time.
    This behavior is allowed both by the R5RS and the R6RS.

    ** Multiple values in compiled code are not represented by compound
       objects

    This change may manifest itself in the following situation:

      (let ((val (foo))) (do-something) val)

    In the interpreter, if `foo' returns multiple values, multiple values
    are produced from the `let' expression. In the compiler, those values
    are truncated to the first value, and that first value is returned. In
    the compiler, if `foo' returns no values, an error will be raised, while
    the interpreter would proceed.

    Both of these behaviors are allowed by R5RS and R6RS. The compiler's
    behavior is more correct, however. If you wish to preserve a potentially
    multiply-valued return, you will need to set up a multiple-value
    continuation, using `call-with-values'.

(It is no longer true that the interpreter and the compiler behave
differently; they behave the same.)

Anyway, if you want a compound values object, use "list", then in your
values-producing expression

> 			 (receive (indices bool x y)
> 			     path-values

use (apply values my-list).

Regards,

Andy
-- 
http://wingolog.org/



      reply	other threads:[~2011-07-14  9:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-09  6:51 vm-error: guile-gnome-2 / treeview / 'button-press-event David Pirotte
2011-07-14  9:07 ` Andy Wingo [this message]

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=87r55tkz7l.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=bug-guile@gnu.org \
    --cc=david@altosw.be \
    /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).