unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* when and unless
@ 2011-06-30 10:44 Andy Wingo
  2011-06-30 21:46 ` Ludovic Courtès
  2011-12-05 20:23 ` Andy Wingo
  0 siblings, 2 replies; 28+ messages in thread
From: Andy Wingo @ 2011-06-30 10:44 UTC (permalink / raw)
  To: guile-devel

I think we should add `when' and `unless' to the default environment.

They go like this:

  (define-syntax when
    (syntax-rules ()
      ((_ test then then* ...)
       (if test (begin then then* ... (if #f #f))))))

  (define-syntax unless
    (syntax-rules ()
      ((_ test else else* ...)
       (if (not test) (begin else else* ... (if #f #f))))))

These are pretty uncontroversial and common, and they make it easier to
read code, so let's do it.

The only argument I have heard against them is that "when" connotes some
connection with time, whereas "if" does not.  I agree with this
criticism, but "when" is sufficiently common that it shouldn't confuse
anyone, and in any case we have modules if someone feels strongly enough
to not want these bindings.

The trailing (if #f #f) is to indicate that the consequent expressions
are evaluated for effect, not for value, and the the return value(s) of
`when' and `unless' are not specified.  In the future we may cause
instances of (if #f #f) used for a value to emit a warning or an error.

Regards,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2012-01-20 20:19 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-30 10:44 when and unless Andy Wingo
2011-06-30 21:46 ` Ludovic Courtès
2011-07-01  7:50   ` Andy Wingo
2011-07-01 12:47     ` Ludovic Courtès
2011-12-05 20:23 ` Andy Wingo
2011-12-06  7:48   ` Marijn
2011-12-06  8:29     ` Alex Shinn
2011-12-06 11:17       ` David Kastrup
2011-12-06 16:25         ` Andy Wingo
2011-12-06 16:42           ` David Kastrup
2011-12-06 17:35             ` Andy Wingo
2011-12-06 22:08               ` David Kastrup
2011-12-06 23:05                 ` Chris K. Jester-Young
2011-12-07  9:23                   ` David Kastrup
2011-12-07 15:58                     ` Chris K. Jester-Young
2011-12-08  8:42                       ` David Kastrup
2011-12-08 15:34                         ` Chris K. Jester-Young
2011-12-08 16:10                           ` David Kastrup
2011-12-08 18:10                         ` Ian Price
2011-12-07 16:10         ` Chris K. Jester-Young
2011-12-06 19:05     ` Chris K. Jester-Young
2011-12-06 19:33       ` Andy Wingo
2011-12-06 14:39   ` Ludovic Courtès
2011-12-07 14:19     ` Ludovic Courtès
2011-12-07 14:27       ` David Kastrup
2012-01-07  0:16       ` Andy Wingo
2012-01-07 22:36         ` Ludovic Courtès
2012-01-20 20:19           ` Andy Wingo

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).