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

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

Re: Transposing words over middle words


From: Emanuel Berg
Subject: Re: Transposing words over middle words
Date: Fri, 17 Nov 2017 01:39:07 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Joseph C. Fineman wrote:

>> TL;DR: How can I transpose words jumping
>> over middle words?
>
> I think that, rather than expending
> cleverness on that particular problem, and
> then trying to remember the result,I would
> write a command that solved a more general
> problem

In general, it isn't better to try to solve the
general problem. The layman mechanic might
think an adjustable spanner is superior to
a (fixed size) combination spanner (the
"U-ring") - but on the contrary, it is much
worse, at least as long as you have the whole
set of metric and imperial sizes - and if you
don't, that's another issue. Specific gear for
specific purposes is what wins the day.

In programming, it is better to solve the
specific problem first, like this

    (count-to-five) ; 1 2 3 4 5

Only when you realize you need to count to four
as well you might consider

    (count-to x) ; 1 .. x

and

    (count-to 4)
    (count-to 5)

But even there, this

    (count-to-five)
    (count-to-four)

isn't always wrong. It depends. (This is a toy
example, of course.)

> & would be easy to remember.

Unless there is DWIM interface I'd say the
general solution can be less easy to remember
as you need to feed it argument(s) and/or tweak
it for the particular situation. Which is
slower than the specific solution, both
invocation and execution, as well.

General solutions are more good-looking tho :)

And you can have both at the same time!
Remember, "make the common [frequent] case fast
and the rare case correct."

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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