help-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Drew Adams
Subject: RE: `when' vs. `and' / `unless' vs `or'
Date: Tue, 16 Oct 2018 16:21:06 -0700 (PDT)

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

> > I use `and' or `or' when the return value is significant.
> > (With `not' as needed.)
> >
> > I use `if' when the true part is a single sexp. If necessary,
> > to respect this I flip the true and false parts (negating the
> > condition).
> 
> So unless it is simple, you always write your big-conditions if as an
> imbrication of both `or' and `and'? isn’t this actually less easy to
> understand (even if easier to read with indentation)?

Dunno what you mean. Isn't what less easy to understand than
what? What's a "big-condition"?

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



reply via email to

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