* Wierd Elispsisms (was: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups.) [not found] <E1V8JCW-0006AY-BZ@vcs.savannah.gnu.org> @ 2013-08-11 11:16 ` Óscar Fuentes 2013-08-11 11:41 ` Juanma Barranquero 2013-08-11 18:28 ` trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups Glenn Morris 1 sibling, 1 reply; 5+ messages in thread From: Óscar Fuentes @ 2013-08-11 11:16 UTC (permalink / raw) To: emacs-devel Juanma Barranquero <lekktu@gmail.com> writes: [elisp/woman.el] @@ -1614,7 +1614,7 @@ (let* ((bufname (file-name-nondirectory file-name)) (case-fold-search t) (compressed - (not (not (string-match woman-file-compression-regexp bufname))))) + (and (string-match-p woman-file-compression-regexp bufname) t))) (if compressed (setq bufname (file-name-sans-extension bufname))) The expressions (not (not (something))) and (and (something-p) t) look bizarre. As someone who is not strong on Elisp, I was puzzled at first. Finally realized that the point is to force a boolean value for `compressed'. Why is so important to use a nil/t value for `compressed'? And, if there exists a reason for using nil/t instead of the original value here and elsewhere, why doesn't exist a function for casting an arbitrary value to a boolean? Using (and ... t) or (not (not ...)) is probably not harder to type than a function, but the function has the advantage of clearly conveying the intention and is safer to edit. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Wierd Elispsisms (was: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups.) 2013-08-11 11:16 ` Wierd Elispsisms (was: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups.) Óscar Fuentes @ 2013-08-11 11:41 ` Juanma Barranquero 2013-08-11 22:33 ` Wierd Elispsisms Óscar Fuentes 0 siblings, 1 reply; 5+ messages in thread From: Juanma Barranquero @ 2013-08-11 11:41 UTC (permalink / raw) To: Óscar Fuentes; +Cc: Emacs developers On Sun, Aug 11, 2013 at 1:16 PM, Óscar Fuentes <ofv@wanadoo.es> wrote: > look bizarre. As someone who is not strong on Elisp, I was puzzled at > first. Finally realized that the point is to force a boolean value for > `compressed'. Both expressions are common enough. > And, if there exists a reason for using nil/t instead of the original > value here and elsewhere, why doesn't exist a function for casting an > arbitrary value to a boolean? Generally speaking, I'd say (not (not X)) or (and X t) can be optimized and a funcall not. But anyway, I suspect the answer is, why use a function when you have a simple idiom every lisp programmer will understand and have quite internalized? To me, what you're asking is as if you objected to the common use of (or x y) instead of (if x x y). Idioms. J ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Wierd Elispsisms 2013-08-11 11:41 ` Juanma Barranquero @ 2013-08-11 22:33 ` Óscar Fuentes 0 siblings, 0 replies; 5+ messages in thread From: Óscar Fuentes @ 2013-08-11 22:33 UTC (permalink / raw) To: emacs-devel Juanma Barranquero <lekktu@gmail.com> writes: > On Sun, Aug 11, 2013 at 1:16 PM, Óscar Fuentes <ofv@wanadoo.es> wrote: > >> look bizarre. As someone who is not strong on Elisp, I was puzzled at >> first. Finally realized that the point is to force a boolean value for >> `compressed'. > > Both expressions are common enough. Grepping for "(not (not " on .el files under lisp/ shows 11 occurrences. Detecting "(and ... t) is harder, so didn't tried. However, if casting a value to a boolean is a common task, that's a strong reason for delegating the job to a function. >> And, if there exists a reason for using nil/t instead of the original >> value here and elsewhere, why doesn't exist a function for casting an >> arbitrary value to a boolean? > > Generally speaking, I'd say (not (not X)) or (and X t) can be > optimized and a funcall not. I guess that the byte-compiler could apply the same optimization to a defsubst. > But anyway, I suspect the answer is, why > use a function when you have a simple idiom every lisp programmer will > understand and have quite internalized? To me, what you're asking is > as if you objected to the common use of (or x y) instead of (if x x > y). Idioms. As already mentioned, they don't look simple to me, but I'm not a Lisp programmer (neither are most Emacs users who at some point try to hack some Elisp). About the idioms, C allows lots of things which are quite "obvious" to the eyes of the expert C hacker and for a long time writing C code on a certain "clever" (read "compressed & mind twisting") way was considered the hallmark of the expert, but nowadays those idioms are often discouraged, as they make the code hard to read and maintain. We could say the same about most languages, with some extreme cases (Perl) All this is IMHO, no big issue, I just was curious. Thanks for explaining Juanma. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups. [not found] <E1V8JCW-0006AY-BZ@vcs.savannah.gnu.org> 2013-08-11 11:16 ` Wierd Elispsisms (was: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups.) Óscar Fuentes @ 2013-08-11 18:28 ` Glenn Morris 2013-08-12 15:12 ` Juanma Barranquero 1 sibling, 1 reply; 5+ messages in thread From: Glenn Morris @ 2013-08-11 18:28 UTC (permalink / raw) To: Juanma Barranquero; +Cc: emacs-devel This broke the test-suite. http://hydra.nixos.org/build/5672580 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups. 2013-08-11 18:28 ` trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups Glenn Morris @ 2013-08-12 15:12 ` Juanma Barranquero 0 siblings, 0 replies; 5+ messages in thread From: Juanma Barranquero @ 2013-08-12 15:12 UTC (permalink / raw) To: Glenn Morris; +Cc: Emacs developers On Sun, Aug 11, 2013 at 8:28 PM, Glenn Morris <rgm@gnu.org> wrote: > This broke the test-suite. I think I found the culprit. J ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-12 15:12 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <E1V8JCW-0006AY-BZ@vcs.savannah.gnu.org> 2013-08-11 11:16 ` Wierd Elispsisms (was: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups.) Óscar Fuentes 2013-08-11 11:41 ` Juanma Barranquero 2013-08-11 22:33 ` Wierd Elispsisms Óscar Fuentes 2013-08-11 18:28 ` trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups Glenn Morris 2013-08-12 15:12 ` Juanma Barranquero
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).