[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `when' vs. `and' / `unless' vs `or'

From: Garreau, Alexandre
Subject: Re: `when' vs. `and' / `unless' vs `or'
Date: Wed, 17 Oct 2018 02:02:28 +0200
User-agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu)

Le 16/10/2018 à 16h21, Drew Adams a écrit :
>> Okay, so what about when you care about the result, but absolutely not
>> about the return value of the condition?
>> (unless cond body) vs (or cond body) -> `or' might imply you might want
>> to return cond.
> I don't understand the question. I use (or ...) when I want to return
> the value of a disjunction, where that value, if non-nil, might be
> any non-nil Lisp value. If (or cond body) returns cond then it's
> because cond is non-nil? What's the question?

I was just saying in the first case it will return nil while in the
second it will return cond (the first arg), so if you don’t want to
return cond (because it’s not what you want) you’ll end up with (and
(not cond) body).

> (And there is no "cond" as in condition versus "body" as in body. `or'
> just returns the first non-nil arg, or nil if none is non-nil.)

It was just to use the same arg names, it doesn’t change anything as you say.

> What's a "big-condition"?

A condition of more than a single sexp, such as (and cond cond) instead
of just cond (which may be (= x 1), so that it would have instead (and
(= x 1) (= x 2)) for instance).

> I use `if' when the code cares about the return value, just like
> `or' and `and'. If the code doesn't care about the return value,
> and if there is only one condition, then I use `when' or `unless'.

> Dunno what you mean. Isn't what less easy to understand than
> what?

(if (or cond cond) then else) than, canonically (and (not (and (or cond
cond) then)) else) (not sure about a simplified version), which is the
way to write it without an `if', as you said you didn’t use it if the
condition was more than a single sexp.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]