From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Chris K. Jester-Young" Newsgroups: gmane.lisp.guile.devel Subject: Re: when and unless Date: Wed, 7 Dec 2011 10:58:34 -0500 Message-ID: <20111207155834.GA15815@yarrow.destinee.acro.gen.nz> References: <87r50ircng.fsf@pobox.com> <4EDDC8B1.3000509@gentoo.org> <87mxb6kkzx.fsf@fencepost.gnu.org> <877h29oeeq.fsf@pobox.com> <877h29k5xs.fsf@fencepost.gnu.org> <8739cxob6z.fsf@pobox.com> <87y5upicaf.fsf@fencepost.gnu.org> <20111206230556.GA14717@yarrow.destinee.acro.gen.nz> <87liqoivle.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1323273555 3804 80.91.229.12 (7 Dec 2011 15:59:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 7 Dec 2011 15:59:15 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Dec 07 16:59:11 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RYJtm-0007tL-CT for guile-devel@m.gmane.org; Wed, 07 Dec 2011 16:59:10 +0100 Original-Received: from localhost ([::1]:55557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYJtl-0007Zj-TL for guile-devel@m.gmane.org; Wed, 07 Dec 2011 10:59:09 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:41872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYJtf-0007XZ-G0 for guile-devel@gnu.org; Wed, 07 Dec 2011 10:59:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYJte-0001Mk-BG for guile-devel@gnu.org; Wed, 07 Dec 2011 10:59:03 -0500 Original-Received: from mail-yx0-f169.google.com ([209.85.213.169]:38322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYJte-0001Ma-3e for guile-devel@gnu.org; Wed, 07 Dec 2011 10:59:02 -0500 Original-Received: by yenq10 with SMTP id q10so740950yen.0 for ; Wed, 07 Dec 2011 07:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=7jB+Hbm22WzWwO7bKFq4X+hBYzUXpUakU2jsS6KWNPc=; b=ZkdwWPAqfbvbUdOysjjlEWzfDfcDfLsdWwCWScLbxfTvVLdTsuAAfo5Jb7j5TCfy28 EbRBWRzq8Qf0dVdlA1nGC4ss+jDivNj2DOFKEYUJltNuYY6AmINAD/ErhVcdV0n6x8jv BXqhU0eSp6W79VA7a708NLMBeXcZGU3WYenNE= Original-Received: by 10.236.190.99 with SMTP id d63mr28407170yhn.73.1323273541330; Wed, 07 Dec 2011 07:59:01 -0800 (PST) Original-Received: from yarrow.destinee.acro.gen.nz (me42c36d0.tmodns.net. [208.54.44.228]) by mx.google.com with ESMTPS id d6sm6005215anm.16.2011.12.07.07.58.59 (version=SSLv3 cipher=OTHER); Wed, 07 Dec 2011 07:58:59 -0800 (PST) Mail-Followup-To: guile-devel@gnu.org Content-Disposition: inline In-Reply-To: <87liqoivle.fsf@fencepost.gnu.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.169 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13009 Archived-At: On Wed, Dec 07, 2011 at 10:23:25AM +0100, David Kastrup wrote: > Lilypond is not Scheme but has a more complex syntax. You can use > Scheme in a lot of places with different implications on the grammar > depending on the type of the expression. It would not be feasible to > create a separate Scheme calling operator for every possible type of > expression. And "called just for action" is one such type. In that case, to be proper, you have to do what the REPL does, which is to wrap the Scheme expression within a call-with-values wherever you process the calling operator. Remember that the continuation can be a case-lambda: (call-with-values (lambda () (values)) (case-lambda (() "No return values") ((x) (format #f "Single value: ~a" x)) (x (format #f "Multiple values: ~a" x)))) (Guile 2.0 has built-in (VM-level) support for case-lambda, which makes this super awesome.) > Well, you'd need to have > > (call-with-values (lambda () *unspecified*) (lambda x (length x))) => 0 [...] > That means that one _only_ needs to consider the implications on > call-with-values continuations. Correct. However, how would you detect whether you're in a context where call-with-values is being used? Here are some things that won't work: 1. You can't walk the stack. Your void expression would be in tail position (it would transfer to the continuation directly, not return to call-with-values---try (call-with-values (lambda () (throw 'foo)) (lambda () 42)) and see what the backtrace looks like). 2. Guile's continuations don't provide meaningful arities: (call/cc (lambda (k) (procedure-minimum-arity k))) always says it takes zero or more arguments. (Same deal applies with Racket, so I presume it's not "just a Guile quirk".) > And it is not like Guile has a problem distinguishing content and > package itself (at least Guile 1.8): > > guile> (write *unspecified*) > #guile> (write (values)) > #guile> In Guile 2.0, multiple values is not a first-class object. Instead, it works like Common Lisp: in any context where a single value is needed, and multiple values are supplied, then only the first value is used, and the rest are thrown away. scheme@(guile-user)> (+ (values 1 2 3) (values 4 5 6)) $1 = 5 scheme@(guile-user)> (+ (values 1 2 3) (values)) ERROR: In procedure values: ERROR: Throw to key `vm-error' with args `(vm-run "Zero values returned to single-valued continuation" ())'. > So I still don't quite see the problem that would arise from making > (eq? *unspecified* (values)) => #t Simply that (values) is not valid to pass to eq?, since eq? is a normal function, that thus expects one value for every argument. That this may possibly work for Guile 1.8 is simply an accident of its implementation of multiple values. Cheers, Chris.