From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.lisp.guile.user Subject: Re: Need help to understand a macro Date: Fri, 19 Mar 2010 08:54:02 -0400 Message-ID: <8E63698F-D6FF-4E42-8B6A-D2DE697C3E98@raeburn.org> References: <20100319085701.GA31143@raven.wolf.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1269003265 28327 80.91.229.12 (19 Mar 2010 12:54:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 19 Mar 2010 12:54:25 +0000 (UTC) Cc: guile-user@gnu.org To: Josef Wolf Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Mar 19 13:54:21 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NsbiX-0008D7-42 for guile-user@m.gmane.org; Fri, 19 Mar 2010 13:54:21 +0100 Original-Received: from localhost ([127.0.0.1]:58629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsbiW-0007N2-HQ for guile-user@m.gmane.org; Fri, 19 Mar 2010 08:54:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsbiS-0007Mt-Ro for guile-user@gnu.org; Fri, 19 Mar 2010 08:54:16 -0400 Original-Received: from [140.186.70.92] (port=39274 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsbiQ-0007Ml-Kf for guile-user@gnu.org; Fri, 19 Mar 2010 08:54:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NsbiP-0003vs-9y for guile-user@gnu.org; Fri, 19 Mar 2010 08:54:14 -0400 Original-Received: from splat.raeburn.org ([69.25.196.39]:57609 helo=raeburn.org) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NsbiH-0003uf-4f for guile-user@gnu.org; Fri, 19 Mar 2010 08:54:13 -0400 Original-Received: from squish.raeburn.org (squish.raeburn.org [10.0.0.172]) by raeburn.org (8.14.3/8.14.1) with ESMTP id o2JCs27p025890; Fri, 19 Mar 2010 08:54:02 -0400 (EDT) In-Reply-To: <20100319085701.GA31143@raven.wolf.lan> X-Mailer: Apple Mail (2.1077) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7679 Archived-At: On Mar 19, 2010, at 04:57, Josef Wolf wrote: > My next question is more related to the defstruct macro. > In line 11, defstruct stores the default initializers into the vv = vector: >=20 > (if (pair? f) (cadr f) '(if #f #f))) >=20 > So if the field is a pair, the initializer is stored in vv. That's = easy. > But if it is not a pair, '(if #f #f) is stored. What is this good for? > This 'if' would evaluate the 'else' part, which does not exist. So we > would get #f as a result. So why not storing #f in the first place? = Why > is not >=20 > (if (pair? f) (cadr f) #f)) >=20 > used here? The result of (if #f #f) is unspecified, not #f, according to r5rs. = That means an implementation can produce whatever value it wants. Guile has a special "unspecified" value which is distinct from #f and = other values, for use when a function's return value is unspecified; in = some ways this is probably better than picking something like #f, as it = doesn't cause people unfamiliar with the distinction between a language = specification and a language implementation to start assuming that #f = (or whatever) is the value that Scheme always requires in that case. = Among other things, the unspecified value causes the REPL to not print a = result: guile> (if #f #f #f) #f guile> (if #f #f) guile> Using (if #f #f) here is basically saying, "the initial value is = unspecified", instead of defaulting to #f or #t or 0 or '() or any other = particular normal value. Ken=