emacs-devel
[Top][All Lists]
Advanced

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

Re: format use inquiry


From: Jean-Christophe Helary
Subject: Re: format use inquiry
Date: Sat, 1 Jul 2017 13:38:50 +0900

> On Jul 1, 2017, at 11:32, Drew Adams <address@hidden> wrote:
> But if we're
> talking about a wholesale change then maybe some
> better approach can be found.

I am certainly not talking about a *wholesale change* but about *1* instance in 
the emacs sources that uses that pattern.

Also, I don't think that *code* is especially bad, but considering what I have 
seen in the rest of the package.el code, this looks more like a way of thinking 
about natural language strings from the authors than about some kind of natural 
lispy rationalization.

Btw, I like your:

(let ((https "https://elpa.gnu.org/packages/";)
     (http   "http://elpa.gnu.org/packages/";))
 (if (gnutls-available-p) https http))

That's something like that that I had in mind.

I am not conflating l10n and anything else btw. But it happens that authors who 
tangle code and strings in general do that all the time without considering 
whether the strings they create are internal or external strings. That leads to 
real problems: my first interest in package.el came from a number of singular 
cases that were not handled, then I checked the code and I found the external 
strings had *lots* of problems (and lots of "rationalizations" to save a few 
lines that ended up creating strings *totally* unlocalizable).

> Just one opinion.

And mine was equally just one opinion, based on greping about a 100 other .el 
files to find similar patterns, where I found that (seemingly) robust code 
would prefer redundancy to smarty formatting.

You may want to compare the tons of redundant urls in auth-source-pass-tests.el 
to that one instance where using format saved the code a few characters (and 
I'm really not sure it adds much in terms of readability).

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

Again ? Sorry if I missed the other references.

That -P flag for CL format contributes to producing just as ugly code as what 
we have here. Code should never be used to create natural language strings with 
syntactic expectation.

Here is the example given in "Common Lisp the Language, 2nd Edition"

(format nil "~D tr~:@P/~D win~:P" 7 1) => "7 tries/1 win" 
(format nil "~D tr~:@P/~D win~:P" 1 0) => "1 try/0 wins" 
(format nil "~D tr~:@P/~D win~:P" 1 3) => "1 try/3 wins"

How do you think that kind of strings can possibly be localized ?

Jean-Christophe 






reply via email to

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