unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Michael Lucy <MichaelGLucy@Gmail.com>
To: guile-devel@gnu.org
Subject: expression
Date: Wed, 23 Jun 2010 16:09:30 -0500	[thread overview]
Message-ID: <AANLkTimRTEQhq1umxlzDizFxkgrSXyRtqj2zi34_iqFk@mail.gmail.com> (raw)

Hey,

Is there any scheme expression that will just get ignored when the
scheme code is compiled?

I'm generating some code with a function like:

(define (gen-update-ab updatea updateb)
  `(begin
     ,(if updatea `(set! a (+ a 1)) `(donothing))
     ,(if updateb `(set! b (+ b 1)) `(donothing))))

And ideally I could replace the donothing function with something that
will get discarded during compilation.

There are alternatives, but they're pretty ugly (significantly moreso
in my actual code than they look below):

(define (gen-update-ab-2 updatea updateb)
  `(begin
     ,@(if updatea `((set! a (+ a 1))) `())
     ,@(if updateb `((set! b (+ b 1))) `())))

(define (gen-update-ab-3 updatea updateb)
  (filter (lambda (x) (not (null? x)))
          `(begin
             ,(if updatea `(set! a (+ a 1)) `())
             ,(if updateb `(set! b (+ b 1)) `()))))



             reply	other threads:[~2010-06-23 21:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23 21:09 Michael Lucy [this message]
2010-06-23 23:14 ` expression No Itisnt
2010-06-23 23:23   ` expression Michael Lucy
2010-06-24 13:01     ` expression Andy Wingo
2010-06-24  6:55 ` expression Ken Raeburn
2010-06-24  7:27   ` expression Thien-Thi Nguyen
2010-06-24  7:52   ` expression Michael Lucy
2010-06-24 13:05     ` expression Andy Wingo
2010-06-24 13:03   ` expression Andy Wingo
2010-06-24 14:40     ` expression Ken Raeburn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimRTEQhq1umxlzDizFxkgrSXyRtqj2zi34_iqFk@mail.gmail.com \
    --to=michaelglucy@gmail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).