From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: conditional code segments Date: Fri, 1 Jun 2018 19:34:23 -0700 Message-ID: <7c307320-d51b-231c-9978-320989fc7641@gmail.com> References: <78397a0b-139c-de1a-2cbf-2458088e1952@gmail.com> <87d0xadk8b.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1527906771 4596 195.159.176.226 (2 Jun 2018 02:32:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 2 Jun 2018 02:32:51 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jun 02 04:32:47 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fOwLW-000153-5Y for guile-user@m.gmane.org; Sat, 02 Jun 2018 04:32:46 +0200 Original-Received: from localhost ([::1]:58119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOwNd-0005b8-71 for guile-user@m.gmane.org; Fri, 01 Jun 2018 22:34:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOwNB-0005ar-RZ for guile-user@gnu.org; Fri, 01 Jun 2018 22:34:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOwN8-0001RM-OR for guile-user@gnu.org; Fri, 01 Jun 2018 22:34:29 -0400 Original-Received: from mail-pg0-x233.google.com ([2607:f8b0:400e:c05::233]:42296) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOwN8-0001QZ-Gw for guile-user@gnu.org; Fri, 01 Jun 2018 22:34:26 -0400 Original-Received: by mail-pg0-x233.google.com with SMTP id p9-v6so12008210pgc.9 for ; Fri, 01 Jun 2018 19:34:26 -0700 (PDT) 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-transfer-encoding:content-language; bh=DNTgAiUAOovwN3eVkaoFtB4/kWz9LDf3jVZE/SyYIeU=; b=usRavjc66IEgGgfssp+Fhb4NnaZtrS4dBuwAwK9muZ6gfpr15CHzsIpgpITf5zyP9a 50pUjZkkVfw0ULgnUeBzWLKIghJUUoGcUpJ/QWZ84icIGC/eVoB8O69BMoIYBzCX7yu2 JOwaqWolsawAk/+ijBdoOoc9MlqDH+s8YMirWXxq+aAqQTJuTxbhwsmxkSbYPVZM30tg 4w400QmyqaHnl5BR2ocGEV1OA4L3LBTQMoZugHeL3LBUNYBPiLvYYhAoWYVQs/WdWcWB uwpHH16Pgv449/lcqSb5/HDmvqlVu6zYmZpYC/gy3g2ryzZwhjKyVs+exomRn3JyPJPj hP4Q== 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-transfer-encoding :content-language; bh=DNTgAiUAOovwN3eVkaoFtB4/kWz9LDf3jVZE/SyYIeU=; b=L/R/5dS6koZ2+fKINlzRyaFuuAWCAXJPcdXlYrZMalEhNEMqXPa0TIh23hHDgjj+wy pDzhKD5+AIv3q+7oJ4xvuXzx8t6UoG1+oyDNv88gYg+2NTm6YyPyJ1G3K9w7DK+NGVSb Fnj9AyBBmb4CW9knRtDT34tbQlk+9hOBUNqCDmv8KJRCc6w2ToboQ1PYXP6bdm9QNz/B ceEZpjk1ykxcKjW8NvP0BTiHsJqSYHV1NpCBs1yDAD3i8UjddfB1sqL7IviVHBjO1u9n DS6ztmPySDvaYZR6msxz4taFy2MEXC4qxsbfpH8wfk2YNLwfRX15iSIHCeOZ1E4Vz1Se 5YsQ== X-Gm-Message-State: ALKqPwdjCGpQjIczEyiCZupuhs7De/S258QCfl5cJ+jqViAT3CEtozIE L92JzjUuqfbHzZAbpt64jrMq6v7T X-Google-Smtp-Source: ADUXVKI0vNRuX//+UPizvFCOiaEKEno9zP5PTuoTCNM0iyY95JtBvNvVzRKWWFoqwi5nCavPqTl+0A== X-Received: by 2002:a65:6604:: with SMTP id w4-v6mr10636152pgv.346.1527906865047; Fri, 01 Jun 2018 19:34:25 -0700 (PDT) Original-Received: from [192.168.2.183] (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id w10-v6sm8633757pfa.135.2018.06.01.19.34.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 19:34:24 -0700 (PDT) In-Reply-To: <87d0xadk8b.fsf@netris.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::233 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14599 Archived-At: On 06/01/2018 06:56 PM, Mark H Weaver wrote: > Hi Matt, > > Matt Wette writes: > >> In C I can use `#ifdef' .. `#endif' to "comment out" code segments. >> >> In Scheme, one can use `#|' and '|#' which is OK but requires dealing with both ends of the >> segment to switch on / off. And emacs (v 24.5) scheme mode does not always fontify the buffer >> correctly with #|...|#. > There's another kind of comment in standard Scheme (both R6RS and R7RS) > that's supported by Guile, but unfortunately it doesn't seem to be > documented in our manual. Simply put the two characters "#;" before any > datum, and the entire datum will be skipped by the reader. Whitespace > may appear between "#;" and the datum. So, for example: > > #; > (let () > ...) > > will cause the entire 'let' form (which is a datum) to be skipped. > Emacs and paredit understand this syntax, and will act accordingly. > > It works not only at top-level, but also nested arbitrarily deeply > within datums. So, for example: > > scheme@(guile-user)> (let () > (display "1\n") > (display "2\n") > #; > (display "3\n")) > 1 > 2 > scheme@(guile-user)> > > and if you put that code in an Emacs buffer in Scheme mode, the > (display "3\n") will be colorized as a comment, but the final closing > parenthesis will have the default color. > I use #; a lot.   So for large number of forms then #;(begin ...) should work. And I didn't know white space can separate the #; from the Scheme form.  Cool. > I tried using cond-expand but it does not work as expected: > scheme@(guile-user)> (cond-expand-provide (current-module) '(abc)) > $1 = (abc) > scheme@(guile-user)> (cond-expand (abc #t)) > While compiling expression: > Syntax error: > unknown file:2:0: cond-expand: unfulfilled cond-expand in form (cond-expand (abc #t)) > It didn't work because when a 'cond-expand' form is used in module FOO, > it looks for the features (e.g. 'abc') in all of the modules that are > imported by FOO, but not in FOO itself. Thanks much.