From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Han-Wen Nienhuys Newsgroups: gmane.comp.gnu.lilypond.devel,gmane.lisp.guile.devel Subject: Re: unhandled constant? Date: Sat, 1 Feb 2020 12:23:51 +0100 Message-ID: References: <8d77f905-31e9-4d0b-973a-82be38360e07@www.fastmail.com> <07e36ec2-0c0c-4786-9040-ffcb3418e0bb@www.fastmail.com> <87blqiwrbo.fsf@fencepost.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="115973"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel@gnu.org, lilypond-devel To: David Kastrup Original-X-From: lilypond-devel-bounces+gnu-lilypond-devel=m.gmane-mx.org@gnu.org Sat Feb 01 12:24:14 2020 Return-path: Envelope-to: gnu-lilypond-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 1ixqsn-000U3b-Qn for gnu-lilypond-devel@m.gmane-mx.org; Sat, 01 Feb 2020 12:24:13 +0100 Original-Received: from localhost ([::1]:45128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixqsm-0005dp-FD for gnu-lilypond-devel@m.gmane-mx.org; Sat, 01 Feb 2020 06:24:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32928) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixqsi-0005di-HB for lilypond-devel@gnu.org; Sat, 01 Feb 2020 06:24:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixqsh-00022h-Bb for lilypond-devel@gnu.org; Sat, 01 Feb 2020 06:24:08 -0500 Original-Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:35717) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixqsf-0001vi-9A; Sat, 01 Feb 2020 06:24:05 -0500 Original-Received: by mail-ot1-x342.google.com with SMTP id r16so9193601otd.2; Sat, 01 Feb 2020 03:24:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nr1zvI6wEQ1Grb5Z0kpS60cBU4XCYaV+hLb6pdDUU98=; b=KDrTJvkRSLeE/ht7nqz6rUWCMCnSYbccn8ze03QYWvsHyo+gcIMWVb3TxiUGt3/YkQ HVCQvwiI9JLZvV/B1uD9Oji1kQYXrbla72qi9uludrRSvyREyQRTiBsStqR67Z06XYnk Qtu9yFFzDwC8eKh0QaMJJbHgqpaBjV20WEQeNV4/LOxnhaCUikhgQmDv2SiQBK1ry6hG qNFgXOgD3oH/BwyIJSX5r0UJfT7wxTsPxW63DRjIoGvm/og6hNVz7X6cktVjKCEQTGwa yJSdmfzIY+0y6DmeAg/AsAGb5ryGKAo3hM3ZTlRcd2Ne5mJWiEKeTc4XecebeT04owpw LU9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nr1zvI6wEQ1Grb5Z0kpS60cBU4XCYaV+hLb6pdDUU98=; b=ELv8AEIjCaHFPG7NCU83fQlOK21ohF+McjmuihgV0PDzj0Lm+3EQTgU90UIe5ZqBZS KLdgx9eI3FTeMz6eqlYh5eAwvdfTFGOG8zZDadecZSpdgLrzoe1NK4suUCF8bt5aQYmm deu8vLjKyCfZwo+DwhJyq68D5U99vC5P+G2a/SwZ99xl+CtX1HVp70zVGpqTWcf/mL7O IO8qxa4hZahrTJ1K7kD3JI5tmPf8XBC1gGYJxZRNTGRG0UF9zJ+LVkFldA+iGnNa10lC wabVqC+mrB94y915Nj2+Zaub8i70SxIWbYRDDUzwZg5XVIseMYBa5f52cRtH0cToMTsu vIow== X-Gm-Message-State: APjAAAUw4s6gOUjOPpQVGDiDDP/nWjF7k2rl8zTunKPrYUM1ppo8iIQc 1gRxlSZjqFcwfJXvI0e0VQCyBxs3RIPI3KAPlQX/tave1u4= X-Google-Smtp-Source: APXvYqxbyBbWlOYNXTBvCTu+F9tbGUAEIXE5fnsbpdsW9TFyaAOm2GNcRFexzRBhUi2pSCSDJ2j/vn06qRGyFK/qiZ8= X-Received: by 2002:a9d:1ca3:: with SMTP id l35mr10930825ota.271.1580556243578; Sat, 01 Feb 2020 03:24:03 -0800 (PST) In-Reply-To: <87blqiwrbo.fsf@fencepost.gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::342 X-BeenThere: lilypond-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions on LilyPond development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lilypond-devel-bounces+gnu-lilypond-devel=m.gmane-mx.org@gnu.org Original-Sender: "lilypond-devel" Xref: news.gmane.io gmane.comp.gnu.lilypond.devel:72488 gmane.lisp.guile.devel:20369 Archived-At: On Sat, Feb 1, 2020 at 11:11 AM David Kastrup wrote: > >> Here is an example that shows better how things work, and what might > >> be the cause of my problems. Is it right that programmatically set > >> contents of "current-module" are not serialized into the compiled > >> file? > >> > >> (define (run-at-compile-time cmd) > >> (module-define! (current-module) (string->symbol cmd) #t) > >> (format (current-error-port) "I-am-called-at-compile-time ~a\n" cmd)) > >> > >> (define (runtime-call cmd) > >> (format (current-error-port) "I-am-called-at-runtime ~a\n" cmd) > >> (format (current-error-port) "val ~a\n" > >> (module-ref (current-module) (string->symbol cmd)))) > >> > >> (defmacro foo (cmd . rest) > >> (run-at-compile-time cmd) > >> `(runtime-call ,cmd)) > >> > >> (foo "xy") .. > >> ERROR: In procedure scm-error: > >> No variable named xy in # > >> > > But that is not using a local define at all. Can you point out the > actual code that failed for you? There are two independent problems. One is a problem with inner defines, which is addressed by https://codereview.appspot.com/553480044/ the symptom is compilation failing with "unhandled constant # " The other is a problem you can reproduce if you check out https://github.com/hanwen/lilypond/tree/guile22-experiment with the symptom being: ;;; compiling /home/hanwen/vc/lilypond/out/share/lilypond/current/scm/define-markup-commands.scm fatal error: Not a markup command: line This is because the LilyPond macro "markup" doesn't recognize markup command and aborts in code that is executed at compile-time. The code that triggers this are definitions in scm/define-markup-commands.scm that use (mark #:blah .. ) in the function body. You can verify this by rewriting https://github.com/lilypond/lilypond/blob/c5ffa540fdbe52486b9575567ede70be575adb47/scm/define-markup-commands.scm#L305 and seeing how the error message changes. I still don't understand why some code is executed compile time (the expansion of the markup macro) while other is not (defining the make-x-markup function in (current-module)) Since we recognize markup commands by looking them up in (current-module), I believe the example I showed here shows that we can never make this work, and we will have to revisit the markup macros completely. -- Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen