From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Fix primitive-eval to return # for definitions Date: Sun, 29 Jan 2012 18:14:33 -0500 Message-ID: <87ehuije3q.fsf@netris.org> References: <87pqe2jfs6.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1327878952 27649 80.91.229.3 (29 Jan 2012 23:15:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 29 Jan 2012 23:15:52 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jan 30 00:15:52 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RrdyR-0007Dx-In for guile-devel@m.gmane.org; Mon, 30 Jan 2012 00:15:51 +0100 Original-Received: from localhost ([::1]:36828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrdyQ-0005zx-PW for guile-devel@m.gmane.org; Sun, 29 Jan 2012 18:15:50 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:48146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrdyN-0005zg-4L for guile-devel@gnu.org; Sun, 29 Jan 2012 18:15:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrdyL-0000VX-RS for guile-devel@gnu.org; Sun, 29 Jan 2012 18:15:46 -0500 Original-Received: from world.peace.net ([96.39.62.75]:34659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrdyL-0000VT-NH for guile-devel@gnu.org; Sun, 29 Jan 2012 18:15:45 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1RrdyG-0005mM-Nq; Sun, 29 Jan 2012 18:15:40 -0500 In-Reply-To: <87pqe2jfs6.fsf@netris.org> (Mark H. Weaver's message of "Sun, 29 Jan 2012 17:38:17 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 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:13738 Archived-At: --=-=-= Content-Type: text/plain I wrote: > Hello all, > > I think the following behavior is inconsistent and undesirable: > > scheme@(guile-user)> (list (compile '(define foo 3))) > $1 = (#) > scheme@(guile-user)> (list (primitive-eval '(define foo 3))) > $2 = (#) > > It doesn't really make sense for 'define' to return a value, because it > cannot be used in expression context. AFAICT, the only way to get this > 'return value' is to call 'eval' or 'primitive-eval'. This weirdness > has bitten Paul Smith in his efforts to port his code to Guile 2. > > I think we should change 'define' to always "return" SCM_UNSPECIFIED, at > least in 2.2. We might also consider nipping this in the bud and making > the same change in 2.0.4. The more I think about it, the more convinced I am that this is simply a bug in our Scheme evaluator. Both our compiler and our bootstrap C evaluator returns SCM_UNSPECIFIED for definitions. Therefore, I would like to nip this in the bud and push the following fix for 2.0.4. What do you think? Mark --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-primitive-eval-to-return-unspecified-for-definit.patch Content-Description: [PATCH] Fix primitive-eval to return # for definitions >From 3509a7f224bc6d7fa4e7eb629a416720eb7256fa Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 29 Jan 2012 17:43:13 -0500 Subject: [PATCH] Fix primitive-eval to return # for definitions * module/ice-9/eval.scm (primitive-eval): Return # for definitions. Previously the variable object was returned. * test-suite/tests/eval.test (evaluator): Add test. * NEWS: Add news entry. --- NEWS | 1 + module/ice-9/eval.scm | 3 ++- test-suite/tests/eval.test | 4 ++++ 3 files changed, 7 insertions(+), 1 deletions(-) diff --git a/NEWS b/NEWS index ce47686..02b824d 100644 --- a/NEWS +++ b/NEWS @@ -180,6 +180,7 @@ Search the manual for these identifiers and modules, for more. ** Fix erroneous check in `set-procedure-properties!'. ** Fix generalized-vector-{ref,set!} for slices. ** Fix error messages involving definition forms. +** Fix primitive-eval to return # for definitions. ** HTTP: Extend handling of "Cache-Control" header. ** HTTP: Fix qstring writing of cache-extension values ** HTTP: Fix validators for various list-style headers. diff --git a/module/ice-9/eval.scm b/module/ice-9/eval.scm index c0fa64c..74b8532 100644 --- a/module/ice-9/eval.scm +++ b/module/ice-9/eval.scm @@ -428,7 +428,8 @@ (let ((x (eval x env))) (if (and (procedure? x) (not (procedure-property x 'name))) (set-procedure-property! x 'name name)) - (define! name x))) + (define! name x) + (if #f #f))) (('toplevel-set! (var-or-sym . x)) (variable-set! diff --git a/test-suite/tests/eval.test b/test-suite/tests/eval.test index f532059..c3121c5 100644 --- a/test-suite/tests/eval.test +++ b/test-suite/tests/eval.test @@ -75,6 +75,10 @@ (with-test-prefix "evaluator" + (pass-if "definitions return #" + (eq? (primitive-eval '(define test-var 'foo)) + (if #f #f))) + (with-test-prefix "symbol lookup" (with-test-prefix "top level" -- 1.7.5.4 --=-=-=--