all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Klaus-Dieter Bauer <bauer.klaus.dieter@gmail.com>
To: Davis Herring <herring@lanl.gov>
Cc: emacs-devel@gnu.org
Subject: Re: RFC: make maphash return a list
Date: Tue, 18 Jun 2013 22:06:35 +0200	[thread overview]
Message-ID: <CANtbJLF7+YHwu1h6KCg0jGvm_o3DimUWWLDFDh8E1Pb_17q6AQ@mail.gmail.com> (raw)
In-Reply-To: <51C07898.6030409@lanl.gov>

[-- Attachment #1: Type: text/plain, Size: 2335 bytes --]

What is easier to read... that would probably be a matter of taste.
Granted, it was a bad example. If find the "nested mapcar" approach easier
to read (though probably not with unmodified indentation rules) when
single-element functions with mapcar and functions operating on lists
alternate, e.g.

  (append
    (mapcar 'function-that-returns-list
      (function-taking-and-returning-lists
        (mapcar 'something-else input-list))))

Basically I find emacs lisp that contains mostly of such "diagonals" the
easiest to read in terms of structure (but this goes beyond the original
topic and to some degree more into indentation conventions).

But subjectively the actually important point is the avoidance of
variables, whose value changes after declaration (preserving a 1-on-1
relation between name and value during execution of the function). Then I
have to find only the let form that declared the variable in order to know
its intended contents rather than scan through the whole function. With
maphash and similiar that style (would that be functional style?) is not
possible.

That said, I have just written a little private-use library for such
things. Bottomline, if I want to program more functionally it doesn't even
take much bending of elisp to do so.

kind regards, Klaus


2013/6/18 Davis Herring <herring@lanl.gov>

> >   (let (mapped-hash) (maphash (lambda (k v) (push (return-something k
> >     v) mapped-hash))) (mapcar 'modification-2 (mapcar 'modification-1
> >     mapped-hash)))
>
> For what it's worth, you can at least here write
>
> (let (mapped-hash)
>   (maphash
>    (lambda (k v)
>      (push (modification-2 (modification-1 (return-something k v)))
>            mapped-hash))
>    hash)
>   mapped-hash)
>
> (so long as the various functions are pure enough to allow the
> reordering).  Indentation makes it longer than
>
> (let (mapped-hash)
>   (maphash (lambda (k v) (push (return-something k v) mapped-hash))
>            hash)
>   (mapcar 'modification-2 (mapcar 'modification-1 mapped-hash)))
>
> (which in 80 columns can even have the tiny line appended to the
> previous), but I think it is conceptually simpler.
>
> Davis
>
> --
> This product is sold by volume, not by mass.  If it appears too dense or
> too sparse, it is because mass-energy conversion has occurred during
> shipping.
>

[-- Attachment #2: Type: text/html, Size: 3752 bytes --]

      reply	other threads:[~2013-06-18 20:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03 17:59 RFC: make maphash return a list Wilfred Hughes
2013-05-03 23:12 ` Pascal J. Bourguignon
2013-05-04  5:29 ` Stephen J. Turnbull
2013-05-05  0:06   ` Wilfred Hughes
2013-06-18  8:17     ` Klaus-Dieter Bauer
2013-06-18 15:11       ` Davis Herring
2013-06-18 20:06         ` Klaus-Dieter Bauer [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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANtbJLF7+YHwu1h6KCg0jGvm_o3DimUWWLDFDh8E1Pb_17q6AQ@mail.gmail.com \
    --to=bauer.klaus.dieter@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=herring@lanl.gov \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.