From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Taylan Kammer Newsgroups: gmane.lisp.guile.devel Subject: Fwd: Re: unhandled constant? Date: Sat, 1 Feb 2020 22:58:31 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="98777"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Cc: guile-devel@gnu.org To: hanwenn@gmail.com Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Feb 01 22:59:22 2020 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iy0nR-000PXn-Rw for guile-devel@m.gmane-mx.org; Sat, 01 Feb 2020 22:59:21 +0100 Original-Received: from localhost ([::1]:51030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iy0nQ-0000x7-UP for guile-devel@m.gmane-mx.org; Sat, 01 Feb 2020 16:59:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34556) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iy0mi-0000In-E2 for guile-devel@gnu.org; Sat, 01 Feb 2020 16:58:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iy0mh-00009P-BX for guile-devel@gnu.org; Sat, 01 Feb 2020 16:58:36 -0500 Original-Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]:39943) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iy0mh-00008R-3P for guile-devel@gnu.org; Sat, 01 Feb 2020 16:58:35 -0500 Original-Received: by mail-lj1-x230.google.com with SMTP id n18so10763484ljo.7 for ; Sat, 01 Feb 2020 13:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:references:to:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lh6VIX/cxd5yyv+hxC5wsamcrnoYgLKrdREN1u7eGoI=; b=t+YhwsnFQVzp9kbUydUZeLBWfr2QO/oILRNL/NnLYDEPinX+cPfVbst35o4eP9O432 udAx7CZv0BRaIxe6CMKZDJr227RBOpbN7kQCVry4m/jU28Et/HvS8XEo0hZYmavXlL9f cUEzodttQ0FQHl19xR2xF5Mtf7q2PZqAo5dwg78HUrpcLjaBMcUOBtGTWIFkjl05QPM9 odPHHAmjOrJgCpS8oNhaFf2uLIikRirewucWyO8iPXMjrZZIlLDQL+yIpFmZgWmJ1R57 YGlNHcjmDQELSnF18DC7+U6wwOW6oUNrwZIPmgOR//oMxd60deS8ktXNL3195v1axger BPXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:references:to:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lh6VIX/cxd5yyv+hxC5wsamcrnoYgLKrdREN1u7eGoI=; b=byEm19vdO5697HwsRzM0PvEuD8D0G/9lq2u+4AmO30gXAwRqVsBQraVjt8TNsoqcRW IF3IEBKo//GfvwTvSAv830s7HfJ0AZt5zB0ALNAeTw5NRlcEj1SH87NOCLltZAQzXS+T EuJzlkdykOhDuCp4HonQRlvMwx2iyPUNYHD0Kt/2TLx1S3CesBL6YvNHUqgltW6WwgTu s+t4HJAg4sMTXrdd0JUvBr592BzLa8IP6Y1oC94Zkj1pBAKzJ7s+3Eq8vvdfAQheUX+X AQpd0RhoVKTwy/aJBAI4tcCA5TgiLiTEfPitRL+6x5j90ZVOYR9I9Ro+DOoEM3SPNLM/ 65LQ== X-Gm-Message-State: APjAAAUVP7oa+S3zlx/t8F65dBiFQ7nD66d6vLfEr4+J9Tq9g8lFrpzo PUVc3g0B0nHT7MftXRKHgouCyOpjnac= X-Google-Smtp-Source: APXvYqyW9dNMUTPj8LvJaTQpQjN7ZQ5qPApPnyUIhAnYYvHblFdlVl+YljZ9JHOBRe4gjnZs84S3pA== X-Received: by 2002:a2e:e12:: with SMTP id 18mr9827512ljo.123.1580594313683; Sat, 01 Feb 2020 13:58:33 -0800 (PST) Original-Received: from [192.168.2.138] ([88.230.140.31]) by smtp.gmail.com with ESMTPSA id y7sm7083158ljy.92.2020.02.01.13.58.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 01 Feb 2020 13:58:33 -0800 (PST) X-Forwarded-Message-Id: In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::230 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20376 Archived-At: (Duplicate of the mail I sent to guile-devel before realizing you're not on the list.) > (defmacro define-session (name value) > (define (inner n v) > (set! decl > (cons > (make-var n v) > decl)) > ) > `(,inner ',name ,value)) The problem here is that the macro output `(,inner ',name ,value) would include a # object, because it evaluates 'inner', which has been defined as a procedure. The raw output would look something like this: (# 'foo "bar) And the compiler tries to put that into a file. But procedure objects cannot be put into a file. (They cannot be "serialized" i.e. turned back into text. Hence the clumsy "#" thing which tells us a bit about the procedure like its name and the number of arguments it takes but doesn't actually include its code.) That's why the compiler chokes. It could put a constant like the number 982346 or the string "foo" or the vector #(x 4 "blah") into the output it generates, because all those objects can be serialized, but a procedure object cannot be truly serialized. Note that something like (lambda () ...) is NOT a procedure; it's a list. Such a list can be evaluated as Scheme code, within a larger context (an "environment"), which then yields a procedure object, but that resulting procedure object cannot be turned back into text, because it might be relying on the environment in which it was defined. Like others pointed out, there's a couple of ways to rewrite that code to avoid putting a procedure object straight into the macro output. For instance, you could put the definition of the procedure into the output, so it will be evaluated (turned into a procedure) at run-time: (defmacro define-session (name value) `(begin (define (inner n v) (set! decl (cons (make-var n v) decl)) ) (inner ',name ,value))) I'm not sure if this code will work verbatim in 1.8 and 2.2, but you get the idea: don't put procedures into macro output. - Taylan On 29.01.2020 00:08, Han-Wen Nienhuys wrote: > Some of the lilypond Scheme files do the following: > > > (define decl '()) > (define (make-var n v) (list "var" n v)) > (defmacro define-session (name value) > (define (inner n v) > (set! decl > (cons > (make-var n v) > decl)) > ) > `(,inner ',name ,value)) > (define-session foo 1) > (display decl) > (newline) > > In GUILE 2.2, this yields > > ;;; WARNING: compilation of /home/hanwen/vc/lilypond/q.scm failed: > ;;; unhandled constant # > > What does this error message mean, and what should I do to address the problem? >