From unknown Sat Aug 16 10:43:39 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24155 <24155@debbugs.gnu.org> To: bug#24155 <24155@debbugs.gnu.org> Subject: Status: SRFI-10: Example from the manual fails to execute. Reply-To: bug#24155 <24155@debbugs.gnu.org> Date: Sat, 16 Aug 2025 17:43:39 +0000 retitle 24155 SRFI-10: Example from the manual fails to execute. reassign 24155 guile submitter 24155 Mathieu Lirzin severity 24155 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 04 21:19:31 2016 Received: (at submit) by debbugs.gnu.org; 5 Aug 2016 01:19:31 +0000 Received: from localhost ([127.0.0.1]:55967 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVTnP-0001LM-Mb for submit@debbugs.gnu.org; Thu, 04 Aug 2016 21:19:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43737) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVTnO-0001LA-Fz for submit@debbugs.gnu.org; Thu, 04 Aug 2016 21:19:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVTnI-00005g-5W for submit@debbugs.gnu.org; Thu, 04 Aug 2016 21:19:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVTnI-000050-2I for submit@debbugs.gnu.org; Thu, 04 Aug 2016 21:19:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVTnF-0003BB-Ur for bug-guile@gnu.org; Thu, 04 Aug 2016 21:19:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVTnC-0008Uw-LZ for bug-guile@gnu.org; Thu, 04 Aug 2016 21:19:21 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVTnC-0008Uq-IT for bug-guile@gnu.org; Thu, 04 Aug 2016 21:19:18 -0400 Received: from arennes-653-1-219-156.w92-139.abo.wanadoo.fr ([92.139.186.156]:59336 helo=godel) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1bVTnA-00082J-U6 for bug-guile@gnu.org; Thu, 04 Aug 2016 21:19:17 -0400 From: Mathieu Lirzin To: bug-guile@gnu.org Subject: SRFI-10: Example from the manual fails to execute. Date: Fri, 05 Aug 2016 03:19:09 +0200 Message-ID: <87popodnci.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.3 (------) Hello, The following example from the Guile manual in subsection 7.5.9, fails for me both on Guile master 2.1.3.94-1a1c3 and Guile 2.0.11 from Debian Testing. --8<---------------cut here---------------start------------->8--- (use-modules (srfi srfi-10)) (define-reader-ctor 'hash (lambda elems (let ((table (make-hash-table))) (for-each (lambda (elem) (apply hash-set! table elem)) elems) table))) (define (animal->family animal) (hash-ref '#,(hash ("tiger" "cat") ("lion" "cat") ("wolf" "dog")) animal)) --8<---------------cut here---------------end--------------->8--- The error is: --8<---------------cut here---------------start------------->8--- While compiling expression: ERROR: build-constant-store: unrecognized object # --8<---------------cut here---------------end--------------->8--- Thanks, -- Mathieu Lirzin From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 07 05:56:00 2016 Received: (at 24155-done) by debbugs.gnu.org; 7 Aug 2016 09:56:00 +0000 Received: from localhost ([127.0.0.1]:58345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWKoK-00065E-EJ for submit@debbugs.gnu.org; Sun, 07 Aug 2016 05:56:00 -0400 Received: from pb-sasl1.pobox.com ([64.147.108.66]:60375 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWKoH-000654-Ho for 24155-done@debbugs.gnu.org; Sun, 07 Aug 2016 05:55:59 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id E0E5229C05; Sun, 7 Aug 2016 05:55:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=sxiKtAWeLJWb /VwrZCTmJ17qmXI=; b=Rd8LnQd15Rbb2tSp0nZSzn2Apu7eW0r46s6fQ3dbwx99 jgA7lChgw2KC2KMZXmdir+UMPYo2FchioHg9lC252D54ErTycWluq1k44vVvV0Bt pzUOx9RUzmo28EgDEPiyP2IiBp8POvm4GRQISGKwKjGceXYajOoXKSEYJr6qVMY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=YZu5nA A+EOiPIEeFDn0hCck/j+UyMG1lENQtN/tZVxmzaee+ZJlZNUqU9eK8k+m5t8luiR gitFiyp574kfqEi6HE8J4+vV3wsj3BHk8K4KwK/WlwNdMO23PWeSJ/ytz7GMhpdK Ek1gXtM64/3Uk9Vfwj3QqdkXLGq9zVTotxmXk= Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id D864C29C04; Sun, 7 Aug 2016 05:55:53 -0400 (EDT) Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id EA05329C03; Sun, 7 Aug 2016 05:55:52 -0400 (EDT) From: Andy Wingo To: Mathieu Lirzin Subject: Re: bug#24155: SRFI-10: Example from the manual fails to execute. References: <87popodnci.fsf@gnu.org> Date: Sun, 07 Aug 2016 11:55:46 +0200 In-Reply-To: <87popodnci.fsf@gnu.org> (Mathieu Lirzin's message of "Fri, 05 Aug 2016 03:19:09 +0200") Message-ID: <87d1lksy1p.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: 20CEEEBC-5C85-11E6-BC69-C1836462E9F6-02397024!pb-sasl1.pobox.com X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: 24155-done Cc: 24155-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Hi Mathieu, Thanks for the report. On Fri 05 Aug 2016 03:19, Mathieu Lirzin writes: > The following example from the Guile manual in subsection 7.5.9, fails > for me both on Guile master 2.1.3.94-1a1c3 and Guile 2.0.11 from Debian > Testing. > > (use-modules (srfi srfi-10)) > > (define-reader-ctor 'hash > (lambda elems > (let ((table (make-hash-table))) > (for-each (lambda (elem) > (apply hash-set! table elem)) > elems) > table))) > > (define (animal->family animal) > (hash-ref '#,(hash ("tiger" "cat") > ("lion" "cat") > ("wolf" "dog")) > animal)) > > The error is: > > While compiling expression: > ERROR: build-constant-store: unrecognized object # I replaced the text with this: We do not recommend #,() reader extensions, however, and for three reasons. First of all, this SRFI is not modular: the tag is matched by name, not as an identifier within a scope. Defining a reader extension in one part of a program can thus affect unrelated parts of a program because the tag is not scoped. Secondly, reader extensions can be hard to manage from a time perspective: when does the reader extension take effect? *Note Eval When::, for more discussion. Finally, reader extensions can easily produce objects that can=E2=80= =99t be reified to an object file by the compiler. For example if you define a reader extension that makes a hash table (*note Hash Tables::), then it will work fine when run with the interpreter, and you think you have a neat hack. But then if you try to compile your program, after wrangling with the =E2=80=98eval-when=E2=80=99 concerns mentioned above, the compi= ler will carp that it doesn=E2=80=99t know how to serialize a hash table to disk. In the specific case of hash tables, it would be possible for Guile to know how to pack hash tables into compiled files, but this doesn=E2= =80=99t work in general. What if the object you produce is an instance of a record type? Guile would then have to serialize the record type to disk too, and then what happens if the program independently loads the code that defines the record type? Does it define the same type or a different type? Guile=E2=80=99s record types are nominal, not structura= l, so the answer is not clear at all. For all of these reasons we recommend macros over reader extensions. Macros fulfill many of the same needs while preserving modular composition, and their interaction with =E2=80=98eval-when=E2=80=99 is w= ell-known. If you need brevity, instead use =E2=80=98read-hash-extend=E2=80=99 and mak= e your reader extension expand to a macro invocation. In that way we preserve scoping as much as possible. *Note Reader Extensions::. Thanks for the report, Andy From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 10 14:51:22 2016 Received: (at 24155-done) by debbugs.gnu.org; 10 Aug 2016 18:51:22 +0000 Received: from localhost ([127.0.0.1]:52599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXYb3-0000hV-V9 for submit@debbugs.gnu.org; Wed, 10 Aug 2016 14:51:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42889) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXYb2-0000hG-L8 for 24155-done@debbugs.gnu.org; Wed, 10 Aug 2016 14:51:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXYau-0004QV-Ao for 24155-done@debbugs.gnu.org; Wed, 10 Aug 2016 14:51:15 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXYau-0004QF-7L; Wed, 10 Aug 2016 14:51:12 -0400 Received: from arennes-653-1-149-168.w92-135.abo.wanadoo.fr ([92.135.12.168]:54196 helo=godel) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1bXYas-0000o2-E3; Wed, 10 Aug 2016 14:51:10 -0400 From: Mathieu Lirzin To: Andy Wingo Subject: Re: bug#24155: SRFI-10: Example from the manual fails to execute. References: <87popodnci.fsf@gnu.org> <87d1lksy1p.fsf@pobox.com> Date: Wed, 10 Aug 2016 20:51:06 +0200 In-Reply-To: <87d1lksy1p.fsf@pobox.com> (Andy Wingo's message of "Sun, 07 Aug 2016 11:55:46 +0200") Message-ID: <87oa50bgpx.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.5 (-----) X-Debbugs-Envelope-To: 24155-done Cc: 24155-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.5 (-----) Andy Wingo writes: > I replaced the text with this: > > We do not recommend #,() reader extensions, however, and for three > reasons. > > First of all, this SRFI is not modular: the tag is matched by name, > not as an identifier within a scope. Defining a reader extension in o= ne > part of a program can thus affect unrelated parts of a program because > the tag is not scoped. > > Secondly, reader extensions can be hard to manage from a time > perspective: when does the reader extension take effect? *Note Eval > When::, for more discussion. > > Finally, reader extensions can easily produce objects that can=E2= =80=99t be > reified to an object file by the compiler. For example if you define a > reader extension that makes a hash table (*note Hash Tables::), then it > will work fine when run with the interpreter, and you think you have a > neat hack. But then if you try to compile your program, after wrangli= ng > with the =E2=80=98eval-when=E2=80=99 concerns mentioned above, the com= piler will carp > that it doesn=E2=80=99t know how to serialize a hash table to disk. > > In the specific case of hash tables, it would be possible for Guile > to know how to pack hash tables into compiled files, but this doesn=E2= =80=99t > work in general. What if the object you produce is an instance of a > record type? Guile would then have to serialize the record type to di= sk > too, and then what happens if the program independently loads the code > that defines the record type? Does it define the same type or a > different type? Guile=E2=80=99s record types are nominal, not structu= ral, so > the answer is not clear at all. > > For all of these reasons we recommend macros over reader extensions. > Macros fulfill many of the same needs while preserving modular > composition, and their interaction with =E2=80=98eval-when=E2=80=99 is= well-known. If > you need brevity, instead use =E2=80=98read-hash-extend=E2=80=99 and m= ake your reader > extension expand to a macro invocation. In that way we preserve scopi= ng > as much as possible. *Note Reader Extensions::. I find this documentation helpful. Thank you. --=20 Mathieu Lirzin From unknown Sat Aug 16 10:43:39 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 08 Sep 2016 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator