[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: format use inquiry
RE: format use inquiry
Fri, 30 Jun 2017 19:32:29 -0700 (PDT)
> Paul suggested that it would be a maintenance hassle to keep 2 almost
> identical urls if we spelled them out as Yuri suggested but I checked other
> source packages and for ex auth-source-pass-tests.el explicitly spells out
> all the urls without resorting to smart formatting to save a few characters.
> Also, considering the way %s is abused in other places package.el, for ex
> (message "%d package%s marked for upgrading."
> (length upgrades)
> (if (= (length upgrades) 1) "" "s")))))
> I don't think it is good to keep the above code because it gives bad
> incentives to authors especially if work on i18n/l10n proceeds (even though
> http/https is not related to l10n).
> So, I'm going to spell out the urls as I proceed with untangling code and
> translatable strings in package.el. I'll send a diff here when I'm done for
FWIW, I think this is a bit misguided. It seems to
be putting translation/localization interests before
code-readability - IOW, making things simpler for some
tools or secondary uses of code, rather than keeping
them simple for someone to read.
I'm not arguing maintenance burden but readability
(which also affects maintenance burden).
Maybe some sacrifice of code simplicity is needed in
the interest of translation-help. But I think another
approach should be sought than what you've proposed.
Code, especially Lisp code, is partly about expressing
something symbolically, to yourself and others who read
If you factor out the part of two things that is common,
that makes it easy to _see_ what is common and what is
If you instead use two URLs that are almost identical
then you make a human reader scan each of them looking
(Did you spot the typo?)
Here the URLs are pretty short, so you might not
get a headache immediately, scanning and comparing.
But imagine the mental load if they were a lot longer.
Or if you had to scan and compare lots of them.
Spend an evening doing that and you might change your
mind about how great it is to duplicate all of that
You could bind a variable to name each one:
(let ((https "https://elpa.gnu.org/packages/")
(if (gnutls-available-p) https http))
(You can come up with better var names.)
That still makes someone scan and compare, but
it at least points out (names) what the expected
difference is. I don't claim it doesn't suffer
from what I complain about above, but it seems a
bit less burdensome to me.
There might be other approaches. None of this
matters much if we're talking only about someone's
preferred style here or there. But if we're
talking about a wholesale change then maybe some
better approach can be found.
Just one opinion.
As for the question of messages that use singular
vs plural forms, I'd again point to Common Lisp's
`format', which addresses that kind of thing (at
least for English).