[developers] dot.emacs redefinition of 'unless' and 'when'
Stephan Oepen
oe at ifi.uio.no
Tue Jan 9 14:45:18 CET 2018
dear mike (and all),
my apologies i did not get to look into this thread earlier! but i am
happy to report that i have just made a change in the LOGON tree to
use private names for these convenience macros. so, once you ‘svn
update’ i hope you will no longer experience unwanted interactions
with third-party emacs lisp code?
for historical background (in case anyone cared): these used to not be
re-definitions because emacs lisp (unlike common lisp) did not provide
when() and unless() in the 1990s. i appear to have added these
convenience definitions to my personal emacs configuration in 1992 and
had not noticed until now that they have become part of standard emacs
lisp in the past few decades.
i agree with your assessment that my macro definition of unless() is
deficient in returning a non-nil value in case the condition is true.
i apparently have never cared about the return values of my unless(),
but i am sorry this property has caused you problems with other emacs
lisp libraries!
with my above patch, i would like to think there is no need to make
changes to other files, e.g. ‘tdl-mode.el’, as entertained by dan.
all should be (back to) good now, i hope, right?
best wishes, oe
On Tue, Dec 19, 2017 at 10:49 PM, Michael Wayne Goodman <goodmami at uw.edu> wrote:
> Sorry, one more change to my original mail. I mistakenly assumed that
> 'unless' was not returning the last value when the condition was false
> (based on some symptoms I was seeing), but I didn't explicitly test this,
> and my lisp is not good enough to deduce this by looking at the defmacro
> expression in ${LOGONROOT]/dot.emacs. In fact, it *does* appear to return
> the last value, but the difference from the default definition is that
> LOGON-unless returns the value of the condition when it's non-nil, rather
> than returning nil.
>
> ; standard unless
> (unless nil 1 2 3) ; returns: 3
> (unless 'value 1 2 3) ; returns: nil
>
> ; LOGON unless
> (unless nil 1 2 3) ; returns: 3
> (unless 'value 1 2 3) ; returns: value
>
> So when LOGON-unless is used in constructing a list, it will (I think)
> append the value of the condition to the list instead of nothing.
>
>
> On Tue, Dec 19, 2017 at 10:18 AM, Michael Wayne Goodman <goodmami at uw.edu>
> wrote:
>>
>> On Tue, Dec 19, 2017 at 8:12 AM, Michael Wayne Goodman <goodmami at uw.edu>
>> wrote:
>>>
>>> Hi Developers,
>>>
>>> Does anyone know why ${LOGONROOT}/dot.emacs redefines the 'unless' and
>>> 'when' macros? It breaks some other Emacs packages I have that depend on the
>>> return value of the 'unless', which should be the value of the last
>>> argument. I'm aware that 'unless' and 'when' should be used when the return
>>> value is *not* important (according to
>>> https://www.emacswiki.org/emacs/WhenToUseIf), but do we have to enforce that
>>> suggestion by redefining the macros so they don't return the last value?
>>>
>>> Also see
>>> https://www.gnu.org/software/emacs/manual/html_node/elisp/Conditionals.html,
>>> which says that 'unless' is equivalent to:
>>>
>>> (if condition nil
>>> a b c)
>>
>>
>> Er... I meant that the guide says `(unless condition a b c)' is equivalent
>> to the above, not in the general case. And I think the expected return value
>> of the 'unless' expression would be c if condition returns nil.
>>
>>>
>>> Thanks
>>>
>>> --
>>> Michael Wayne Goodman
>>> Ph.D. Candidate, UW Linguistics
>>
>>
>>
>>
>> --
>> Michael Wayne Goodman
>> Ph.D. Candidate, UW Linguistics
>
>
>
>
> --
> Michael Wayne Goodman
> Ph.D. Candidate, UW Linguistics
More information about the developers
mailing list