From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.devel Subject: Re: unhandled constant? Date: Fri, 31 Jan 2020 19:19:52 +0100 Message-ID: References: <8d77f905-31e9-4d0b-973a-82be38360e07@www.fastmail.com> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="4722"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.1.7-781-gfc16016-fmstable-20200127v1 Cc: guile-devel@gnu.org To: "Han-Wen Nienhuys" Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Jan 31 19:20:31 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 1ixau6-00019v-DE for guile-devel@m.gmane-mx.org; Fri, 31 Jan 2020 19:20:30 +0100 Original-Received: from localhost ([::1]:57708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixau5-00084J-0L for guile-devel@m.gmane-mx.org; Fri, 31 Jan 2020 13:20:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55457) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixats-000837-FV for guile-devel@gnu.org; Fri, 31 Jan 2020 13:20:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixatq-0007J2-Us for guile-devel@gnu.org; Fri, 31 Jan 2020 13:20:16 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:46685) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixatq-0007H3-Kc for guile-devel@gnu.org; Fri, 31 Jan 2020 13:20:14 -0500 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 1664421B2F; Fri, 31 Jan 2020 13:20:14 -0500 (EST) Original-Received: from imap1 ([10.202.2.51]) by compute3.internal (MEProxy); Fri, 31 Jan 2020 13:20:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=veryfast.biz; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type:content-transfer-encoding; s=fm1; bh=rfLNE cinmUE6ZcZ/bVprAgzMAASCs88mMG69AbpO03Q=; b=khqMxrENzZ08xK6RY4ZID +WU4cdfkhdRf+N/wYryE8lKcXJpyCyhlqcB7U+4ptj5l/6RZVU2DtM1egwr6yFAj 2Jo+T6PbiRf7A4LN/X+HIM8tlZYEUZVXK+noeFUZoWiRPBFnxg1ul0F7qmqlbprk gCoeGQUC71STqaZoWgQwqq3/cxPzPMf20OLkvFj4IXVY/H3ky9Cg3K3O8u36xrsL TWgPB3feGsTGFg1X+50iGtriwN9LtJp1NmaGJlMmS7qZf6xEgnv7TVAO0ZA+Ww4E Hb421HdfhWF76cwujvsJ9oyjufdS/cYzQGh+eik95T/n+FosfGGy+Wz1kELIu7pj g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=rfLNEcinmUE6ZcZ/bVprAgzMAASCs88mMG69AbpO0 3Q=; b=cIDWBUR72bXoA9hA2HZEm1CWt4Abn56eCiqcsy9037oxnhPExf7AloWqu FzLRyEfRa4D2WBcHAiSefCEySRRxmRwYRVNrkn2Qx9ODVLPxh0C8JHEG+HBvqcvI syd1TKkU92K+B1Gv81eD5eJfOcCHm5e1qVkrmtWlhbN32PI5Fz3AF6B/Ong/M7xu oZG+wyaY4/1E5C88xqsxz/KENRNldwKfqr3eDAXQqbI4Z2NeLbAQUWZ5peQkFOiR 3dQF8/8mKjgQQtblnlxEcDZ2l2VCgDqCQpXHtqXmVETfTgXjIydDt4IX5+rwASsB dnLZSgGKto5RjW0ZYt0hJ6T5+xJLg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrgedtgddutdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepnfhinhhushgpuehjnphrnhhsthgrmhcuoehlihhnuhhs rdgsjhhorhhnshhtrghmsehvvghrhihfrghsthdrsghiiieqnecuffhomhgrihhnpeigsh egrghllhdrnhhlnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheplhhinhhushdrsghjohhrnhhsthgrmhesvhgvrhihfhgrshhtrdgsihii X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id D5A23C200A4; Fri, 31 Jan 2020 13:20:13 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.25 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:20360 Archived-At: I'm not very familiar with how guile 1.8 works since my first guile vers= ion was 2.2, but I remember hearing Andy talk about how macro expansion = was done at runtime, due to guile not being compiled. I just put one and one together and figured that the reason the macro yo= u posted works in 1.8 must be because of what basically rounds down to n= o separation between runtime and expand time. Defmacro is expanded to a regular syntax case macro that first strips al= l syntax information and passes it to the defmacro body and the re-intro= duces the result. Regarding your other question: any literal string in t= he defmacro body is moved to the correct define-syntax placement. I don't really understand your question. With defmacro and syntax-case y= ou can run arbitrary code. If you just output code that does module-defi= ne! that won't be run until runtime, and thus you cannot depend on the r= esult of that module-define! during expansion. You can however wrap it i= n an eval-when to solve that issue. That allows you to specify when code= gets run. With module-define! I personally find it all a bit icky, but = I usually stay as far away from phasing as I can :) --=20 Linus Bj=C3=B6rnstam On Fri, 31 Jan 2020, at 18:50, Han-Wen Nienhuys wrote: > On Fri, Jan 31, 2020 at 3:58 PM Linus Bj=C3=B6rnstam > wrote: > > > > Guile1.8's macros are run-time macros: they are executed directly an= d not transformed to output code that is then compiled. That is the reas= on why your code works: to newer guiles the (inner ...) is only availabl= e at expansion time. The macro output is trying to call code that does n= ot exist at runtime! >=20 > When is the code executed? If have complex set of macros to define a > special type of functions (so called markup commands). Some of these > refer to other markup commands through a macro. >=20 > What I can observe that some of the functions involved are not called > during the compilation, but others are. >=20 > In particular, the function that registers a markup command using some= thing like >=20 > (module-define! (current-module) > (string->symbol (format #f "~a-markup" name)) defn)) >=20 > but this function is not called during the compile >=20 > There is a convenience macro that is called within some function > bodies, that does get called. Unfortunately, the latter convenience > macro is expanded and then executed; the execution tries to then do >=20 > (module-ref (current-module) > (string->symbol (format #f "~a-markup" name) >=20 > which fails. >=20 >=20 >=20 > > For this to be working code the (inner ...) function needs to be ava= ilable in the macro expansion. I didn't read through exactly what you ar= e trying to do, but try outputting a let: > > > > `(let ((inner (lambda (n v) (set ! ...)))) > > (inner ,name ,value)) > > > > I doubt you can make the old code work in newer guiles, since I doub= t any scheme is a s lax about expansion time and macro time separation. > > -- > > Linus Bj=C3=B6rnstam > > > > On Wed, 29 Jan 2020, at 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? > > > -- > > > Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwe= n > > > > > > >=20 >=20 >=20 > --=20 > Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen >