[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conditional code segments
From: |
Alex Vong |
Subject: |
Re: conditional code segments |
Date: |
Sat, 02 Jun 2018 09:11:45 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Matt Wette <address@hidden> 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 #|...|#.
>
> I can use (if #f (begin ....)) but it's not pretty and indents 4 spaces (or
> an ugly 1 space).
>
> 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))
>
> My current attempt is to add this:
>
> (define-syntax-rule (if-true form ...) (begin form ...))
> (define-syntax-rule (if-false form ...) (begin))
>
> (if-false
> (define x ...)
> ...
> )
>
> (if-true
> (define x ...)
> ...
> )
>
> Any other solutions / suggestions?
Maybe you can try to use #; to comment out s-exp? I prefer this way
because it feels very lispy to me.
signature.asc
Description: PGP signature