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: Re: unhandled constant? Date: Sat, 1 Feb 2020 22:55:15 +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="79527"; 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 To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Feb 01 22:56:14 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 1iy0kQ-000KZ4-MV for guile-devel@m.gmane-mx.org; Sat, 01 Feb 2020 22:56:14 +0100 Original-Received: from localhost ([::1]:51024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iy0kP-0008F9-OZ for guile-devel@m.gmane-mx.org; Sat, 01 Feb 2020 16:56:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33810) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iy0jZ-0007e1-48 for guile-devel@gnu.org; Sat, 01 Feb 2020 16:55:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iy0jX-0008Og-U0 for guile-devel@gnu.org; Sat, 01 Feb 2020 16:55:21 -0500 Original-Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]:39264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iy0jX-0008JT-Lv for guile-devel@gnu.org; Sat, 01 Feb 2020 16:55:19 -0500 Original-Received: by mail-lj1-x230.google.com with SMTP id o15so5232900ljg.6 for ; Sat, 01 Feb 2020 13:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=QO/Ygbg0i85JiYOmeQzc56BIV2tWAiAocdg7L08QRxc=; b=LShDzoFeQSLXulrGBdNBODFd/7uGt1vNLxlIcs0DRbu+CKwwYdq8um950FEhI05i6+ aBCV4DfsbBRctgndCJxtVegCSUbFqiKAG9EOr1T9apEBFMQaq+HVMuA5PZTNx6Ar3qjH pTfu5gohEsN+SP7vSCdM5eh72xW/69FzgnMZ8yk+L7DFKH/hOdX17uUUxlHg0rKfJaII my6y7W85Xnu9IvfNxW121+jymsY1qBvjvY/s/WBt6R0qbl3foMpNok4zhBTzhi8Mud5M JQDGOZlkskQP92hJ/tKqdsC7BKhHU9vJsN6Sjq76RK1A9JzskxaMIFAf49rz5BcKdHTv mTjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QO/Ygbg0i85JiYOmeQzc56BIV2tWAiAocdg7L08QRxc=; b=Pq+4yg+chLbUMVsxVcU2kUstYn5cKBH4DhPjqVEHv4KjncMvr2YM/uHtuRRy2KMng4 Bq4HjdrXGaXfs7v0CeHSO75w5fiuYkwUDR6pPwl69vKoVxMPMq3Oe2z2IDIVRW1qOmNC EH4gayohyKUFNoWFsb4SV5yGonQgx+LGzNZPcUKRdOIUwWJhibjrv4tgdhXXVK+bTwss 6E2X6N2s236flCL1H33TMlQA9hiToaEkkZzvnfMmGjbrrbSEkAA5j5oZN3v646DWwhCX UOOp2kEFCo78FUaKUjkxpS3sDRzjke1TwsippdQSD/Wndx+Rj1YOdbksPf2Vp1LCXdYP wVbQ== X-Gm-Message-State: APjAAAVLX+hxSFZVIt/sUm/9hibDjXm7FZ8GRvBv9rwyFu8bXV0S37Ej bUDW5djRnzwX4yNgEsfujuQcNUoPNBQ= X-Google-Smtp-Source: APXvYqwmIyXtNG69spWcznRRkZYwHwxMHnmnVcn3u6MJVHiXgLNfZr28INxVpUqWbxAsvOoGqatueA== X-Received: by 2002:a2e:8797:: with SMTP id n23mr9089850lji.176.1580594117890; Sat, 01 Feb 2020 13:55:17 -0800 (PST) Original-Received: from [192.168.2.138] ([88.230.140.31]) by smtp.gmail.com with ESMTPSA id r26sm6511638lfm.82.2020.02.01.13.55.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 01 Feb 2020 13:55:17 -0800 (PST) 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:20375 Archived-At: > (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? >