emacs-devel
[Top][All Lists]
Advanced

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

Re: constant `e'


From: Daniel Brockman
Subject: Re: constant `e'
Date: Sat, 10 Feb 2007 12:35:30 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.51 (gnu/linux)

David Kastrup <address@hidden> writes:

> Daniel Brockman <address@hidden> writes:
>
>> Seriously, though, I'd really like to see an `otherwise'
>> constant (defined to `t', of course).  That would make
>> catch-all clauses of `cond' look much better.
>
> Disagree, that's an idiom.

Of course it's an idiom.  That doesn't mean it looks good.
I, as a speaker of Emacs Lisp, would prefer not to use this
idiom if `otherwise' became an accepted alternative.

Why?  Because I simply think this looks ugly:

  (cond ((not (null n))
         (bongo-mark-line-forward (prefix-numeric-value n)))
        ((bongo-region-active-p)
         (bongo-mark-region (region-beginning) (region-end)))
        (t
         (bongo-mark-line-forward)))

It looks as if the last arm is about to break and fall off.
I think this looks better:

  (cond ((not (null n))
         (bongo-mark-line-forward (prefix-numeric-value n)))
        ((bongo-region-active-p)
         (bongo-mark-region (region-beginning) (region-end)))
        (otherwise
         (bongo-mark-line-forward)))

Incidentally, I also think `(not (null n))' looks better
than `n' --- as do, I believe, most Emacs Lisp programmers.
Take a look at this code:

  (cond (n
         (bongo-mark-line-forward (prefix-numeric-value n)))
        ((bongo-region-active-p)
         (bongo-mark-region (region-beginning) (region-end)))
        (t
         (bongo-mark-line-forward)))

It's ugly, isn't it?  It's not just that `(not (null n))' is
semantically clearer than a lone `n'; it's also more beautiful.

> Anyway, you can do
>
> (cond ((eq x 'yellow) "yellow")
>       ((eq x 'green) "green")
>       ("other"))
>
> and avoid the t altogether.  Not that it is prettier to
> my eyes.

Interesting.  I think I'll try that for a while.

  (cond ((not (null n))
         (bongo-mark-line-forward (prefix-numeric-value n)))
        ((bongo-region-active-p)
         (bongo-mark-region (region-beginning) (region-end)))
        ((bongo-mark-line-forward)))

It looks a little weird, but maybe I'll get used to it.
It certainly is prettier to my eyes.  Thanks.

>> Please?
>
> There is no point in Elisp diverging from Lisp without
> more compelling reasons.

The `case' macro already allows `otherwise'.  That's a
pretty compelling reason to allow it in `cond' as well.
(Yes, I know `case' is in the `cl' library, but lots of
people use that library --- at least its macros.)

-- 
Daniel Brockman <address@hidden>





reply via email to

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