From: Drew Adams <drew.adams@oracle.com>
To: Oleh Krehel <ohwoeowho@gmail.com>
Cc: Jordon Biondo <jordonbiondo@gmail.com>,
rms@gnu.org, Stefan Monnier <monnier@IRO.UMontreal.CA>,
emacs-devel@gnu.org
Subject: RE: giving `setq-local' the same signature as `setq'
Date: Thu, 19 Mar 2015 10:25:19 -0700 (PDT) [thread overview]
Message-ID: <6e39610c-c64d-412c-9024-e4116589fbec@default> (raw)
In-Reply-To: <87vbhx2d8k.fsf@gmail.com>
> > You can do the same for `let*', if you like:
> > (let ((foo fooval))
> > (let ((phlop phlopval))
> > (let ((toto totoval))
> > ...)))
>
> Now you've just lead yourself into a trap. This is similar to
> one-var-per-setq:
> (let* ((foo fooval)
> (phlop phlopval)
> (toto totoval))
> ...)
No, one var per `let' would be as I showed it - 3 `let's for 3 bindings.
Using `let*' with multiple vars is analogous to using `setq' with multiple
vars. `setq' assigns and `let*' binds, but they both let you give values
to multiple variables. Or to only one variable at a time - your choice.
> This is similar to multi-var-per-setq:
> (let* (foo fooval
> phlop phlopval
> toto totoval)
> ...)
No, that is simply malformed code.
> >> It also gives an anchor to quickly navigate to the variable
> >> to get its value.
> >
> > How so? Please elaborate.
>
> With C-M-n and C-M-p you can navigate to the big fat paren by which the
> variable resides (after setq).
OK.
> >> In a setq list of 10 items, by item 5 it is already unclear which is the
> >> variable and which is the value. In my opinion, it's not worth
> >> complicating the code maintenance just to save a few chars.
> >
> > This is why it is good that you have the choice.
>
> You're wrong here. I don't have the choice. Just yesterday I was debugging
> my AUCTEX config. It wasn't pleasant to navigate 5-variable setq
> statements, some of which took the whole page.
That problem is independent of this discussion, unless you are referring
to the convenience of your using `C-M-p' to move to individual assignments.
One can write bad code, with 473 `setq's in a row or with a single `setq'
that has 473 assignments. Being able to group assignments in a single
`setq' does not require anyone to use many assignments in a row.
> > I find it clearer to let `setq' do the grouping, instead of implicit or
> > explicit `progn'. But I put each var & value pair on a separate line:
> >
> > (setq foo fooval
> > phlop phlopval ; Maybe this one needs a comment.
> > toto totoval)
> >
> > I don't do this to save characters (e.g. for typing). I do it to make
> > the code clearer and maintenance less error prone and easier. For me,
> > at least.
>
> Imagine that you want to comment out `phlop phlopval', which is a
> multi-line statement. If it was bounded by parens, you could do it in an
> easy and error-free way. Otherwise, you have to manually select the region.
Actually, `phlop phlopval' is a single line, and can be commented out simply.
But I take your point. Yes, the style I prefer can mean extra typing.
To me it's worth it, for the sake of clearer code (IMO). But you don't
need to write code the way I prefer. And you don't need to maintain my
code.
If you work with a team to create and maintain code, then it can help to
decide what the team prefers, in terms of coding style. That's not
limited to this discussion about `setq'.
What is germain to this discussion is that different teams can choose
what they want, wrt using separate `setq's for multiple assignments.
What you propose is that for the sake of "consistency" there must be,
in effect, only one team: the choice should be made for Emacs Lisp as
a whole, instead of letting those who use it decide.
I prefer that Emacs Lisp be consistent with, well, LISP in this regard.
Multiple assignments for `setq' have been around since the 60s in Lisp
(but no, they were not in Lisp 1.5). At least two of us like it that way.
prev parent reply other threads:[~2015-03-19 17:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-18 15:26 giving `setq-local' the same signature as `setq' Jordon Biondo
2015-03-18 16:24 ` Stefan Monnier
2015-03-19 14:08 ` Richard Stallman
2015-03-19 14:48 ` Jordon Biondo
2015-03-19 15:11 ` Drew Adams
2015-03-19 15:17 ` Oleh Krehel
2015-03-19 15:39 ` Drew Adams
2015-03-19 15:55 ` Oleh Krehel
2015-03-19 17:25 ` Drew Adams [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e39610c-c64d-412c-9024-e4116589fbec@default \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=jordonbiondo@gmail.com \
--cc=monnier@IRO.UMontreal.CA \
--cc=ohwoeowho@gmail.com \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).