From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Taylan Ulrich Bayirli/Kammer Newsgroups: gmane.lisp.guile.user Subject: Re: Why is an empty lambda body not allowed? Date: Sat, 05 Jul 2014 01:01:39 +0300 Message-ID: <871tu0eqbg.fsf@taylan.uni.cx> References: <877g3tdkvs.fsf@taylan.uni.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1404511373 14869 80.91.229.3 (4 Jul 2014 22:02:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Jul 2014 22:02:53 +0000 (UTC) Cc: "guile-user@gnu.org" To: Tobias Brandt Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jul 05 00:02:46 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X3BZ8-0004v1-6a for guile-user@m.gmane.org; Sat, 05 Jul 2014 00:02:46 +0200 Original-Received: from localhost ([::1]:38213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3BZ5-0005oN-Dm for guile-user@m.gmane.org; Fri, 04 Jul 2014 18:02:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3BYn-0005o7-VT for guile-user@gnu.org; Fri, 04 Jul 2014 18:02:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X3BYe-0004J7-Tn for guile-user@gnu.org; Fri, 04 Jul 2014 18:02:25 -0400 Original-Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:62305) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3BYd-0004Ie-Ln for guile-user@gnu.org; Fri, 04 Jul 2014 18:02:16 -0400 Original-Received: by mail-we0-f173.google.com with SMTP id t60so2144944wes.18 for ; Fri, 04 Jul 2014 15:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=FdoMHd0kNLoZKgHE2w2RCXbVlMobZPrnZH6qbRil+iU=; b=P/MyyWir6pWVujvkSFumn9C+aQA1AeDl52Rm1qLkrMdVkn9mVt43bHO0eIC6Zfxfe6 N8EEgM+wGOOJyX7Nw+vb0G3xwLJzuu8KTo7UxULyhBm85mQSVfJQZn7bxqxKY23QqOuV dSxOPJkbYLmIAo4b1EUUr1KZS4fW2RJztzLnjnQzI5ZdzDlI2jNwgluB636am7sPRms0 jP9B+3RJQuB+oAVoJVjZEkXkpmgMLSwOYVgQkjO15vLSlGWMWovUTKrzSpbyTr2TBUNu TXONrFgMe0zTX1FE00xs5oGJub2noY7IIVw8OarCB83E//bRE4InVgDmcBtDx0lh3MbD OPKA== X-Received: by 10.194.1.164 with SMTP id 4mr14847523wjn.17.1404511333771; Fri, 04 Jul 2014 15:02:13 -0700 (PDT) Original-Received: from taylan.uni.cx ([85.100.205.21]) by mx.google.com with ESMTPSA id ft2sm74634307wib.1.2014.07.04.15.02.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jul 2014 15:02:13 -0700 (PDT) In-Reply-To: (Tobias Brandt's message of "Fri, 4 Jul 2014 21:14:43 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22d X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11324 Archived-At: Tobias Brandt writes: > I don't really care what (lambda ()) evaluates to as long as it's > consistent with the rest of the language. But what rubs me the wrong > way is that > > (define x (begin)) > (lambda () x) > > is not the same as > > (lambda () (begin)) > > because one of the strength of functional programming is referential > transparency. Therefore I would expect the definition of x (which has > no side effects) to be substitutable for x itself. This is apparently > not the case as one (begin) has a different meaning than the other > because of its context. I agree it's annoying. However it only breaches referential transparency on a superficial, textual level, or not at all depending on your definition. In your example, the right-hand side of the `define' is (grammatically) an whereas the other form is in a position, so it's not so that you're exchanging two s. It's rather so that a valid (in Guile Scheme at least, see below) happens to also be a valid (which however leads to an error later on). By the way, it comes out the expression-begin is actually specified (in R5 through 7RS) to take at least one operand, so in your example the (define x (begin)) is unspecified in first place. OTOH, a is defined as "* ", where is "* ", meaning that in a that is just "(begin)", the (begin) is an . In RnRS, (begin) is actually an invalid , but since Guile allows it in general, one would expect it to work here too. (Guile's "excuse" here could be that it uses a wholely different grammar that is compatible with the RnRS one, instead of one constructed through incremental extensions to it.) I now wish Guile simply didn't allow (begin) as a valid expression. :-) While this is just a nitpick, I'll file a bug report for it. > As another data point, this seems to be fine: > > (use-modules (oop goops)) > (define-method (foo)) > > So, GOOPS doesn't mind empty method bodies. However > > (define-method (foo) (begin)) > > fails. Not very consistent either, I'm afraid. I just checked and `define-method' (deferring to the auxilliary macro `method') special-cases zero-form method bodies, simply giving them a body of (if #f #f), so it introduces the asymmetry intentionally. Dunno why, but changing it could break backwards compatibility. OTOH it's nasty that the second failes when the first doesn't, so I'll file an additional report for that. > Cheers, > Tobias Taylan