Othewise

47 views
Skip to first unread message

Maciek Godek

unread,
Oct 11, 2021, 5:38:20 AM10/11/21
to
I sometimes find it convenient to be able to specify the "short-circuiting" of the "or" operator in the reverse order.

This happens in particular when I use the "and-let*" form, and I want to provide the default alternative:

Instead of

(or
(and-let* (...)
...)
default-value)

it might be preferable to write:

(otherwise default-value
(and-let* (...)
...))

where "otherwise" is defined trivially as

(define-syntax otherwise
(syntax-rules ()
((_) #false)
((_ expression) expression)
((_ expression . expressions)
(or (otherwise . expressions) expression))))

(so it effectively reverses the order of arguments to "or")

Do you think "otherwise" is a good name for this?
Or are there any alterantives that you'd recommend?

Amirouche Boubekki

unread,
Nov 9, 2021, 5:25:20 AM11/9/21
to
If the goal is to reverse `or`, why not write `(or c b a)` instead of `(or a b c)`?

George Neuner

unread,
Nov 13, 2021, 12:42:09 AM11/13/21
to
In keeping with other wrappers, perhaps "with-default"?

YMMV,
George
Reply all
Reply to author
Forward
0 new messages