• Othewise

    From Maciek Godek@21:1/5 to All on Mon Oct 11 02:38:18 2021
    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Amirouche Boubekki@21:1/5 to godek....@gmail.com on Tue Nov 9 02:25:18 2021
    On Monday, October 11, 2021 at 11:38:20 AM UTC+2, godek....@gmail.com wrote:
    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?

    If the goal is to reverse `or`, why not write `(or c b a)` instead of `(or a b c)`?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From George Neuner@21:1/5 to godek.maciek@gmail.com on Sat Nov 13 00:42:03 2021
    On Mon, 11 Oct 2021 02:38:18 -0700 (PDT), Maciek Godek
    <godek.maciek@gmail.com> wrote:

    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?

    In keeping with other wrappers, perhaps "with-default"?

    YMMV,
    George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)