all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Fren Zeee <frenzeee@gmail.com>
To: Thien-Thi Nguyen <ttn@gnuvola.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to remove verbosity from the data passing mechanism using alist or plist ?
Date: Mon, 6 Dec 2010 07:41:21 -0800	[thread overview]
Message-ID: <AANLkTik0B6kVH57GuKLsRxO0ks6XB_C4VVxqBVK40gBJ@mail.gmail.com> (raw)
In-Reply-To: <87lj43at0i.fsf@ambire.localdomain>

On Mon, Dec 6, 2010 at 6:13 AM, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
> [cc changed to help-gnu-emacs -- this does not belong on emacs-devel]
>
> () Fren Zeee <frenzeee@gmail.com>
> () Sun, 5 Dec 2010 12:15:08 -0800
>
>   [code]
>
> Here is ‘find-my-marker-GOLD’, munged a bit:
>
> (defun find-my-marker-GOLD ()
>  "Starting from anywhere in the file, find my marker GOLD its value
>   and location."
>  (interactive)
>  (save-excursion
>    (save-match-data
>      ;; Starting from the end of the accessible region, find GOLD.
>      (goto-char (point-max))
>      ;; a/ This value of this expression is discarded.
>      ;;    It turns out to be the same as "location" below,
>      ;;    so if you save it, you can avoid a call to ‘point’.
>      ;; b/ The optional args default to ‘nil’, and can be dropped.
>      (search-backward-regexp "GOLD=\\([0-9]+\\)\n" nil nil nil)
>
>      ;; In the following, i have deleted the eol comments, which
>      ;; obscure more than enlighten (on my small computer screen).
>
>      ;; You might consider using `((k0 . ,v0)
>      ;;                            (k1 . ,v1))
>      ;; for succinctness (note backquote and comma placement).
>      ;; An intermediate solution is to use ‘acons’.
>      (list
>       (list
>        :GOLD-value
>        ;; The ‘replace-regexp-in-string’ is not necessary.
>        ;; The initial regexp match (above) already sets the match
>        ;; data; you can use ‘(match-string 1)’ to retrieve it.
>        (string-to-number
>         (replace-regexp-in-string "GOLD=\\([0-9]+\\)\n" "\\1"  (match-string 0))))
>       (list
>        :GOLD-location
>        (point))))))
>
>   [Q] Are there any defects in this method of passing struct and what
>   improvements are possible ?
>

> All defects are misalignments of intention and implementation.
> If you don't know your intention clearly, it's easy for a defect
> to creep in.  Improvements, likewise, depend on intention and pov.

Excellent point.

>
>       Specifically, are there ways to reduce verbosity without using cl
>   or staying purely in elisp ?
>

> You can use shorter variable names.  You can make your program
> less piecewise-constructive and more table-oriented.

I would certainly need a toy example or even ask for taking this
example and showing me how to do it. I am not familiar with this
table-oriented approach.

>   [Q] Is there a way to avoid lengthy calling statement like
>         (car (assoc-default :GOLD-value    GOLD )
>       inside let,
>
>       since the first argument of let is an alist of the form
>            ((sym1 val1) (sym2 val2))
>

> You need the ‘car’ because you do ‘(list k v)’.
> If you use ‘(cons k v)’, then you do not need the ‘car’.

Good point

>
>   [Q] Is there a way to using plists for return from find-my-marker-GOLD
>       and utilize in the user function test-GOLD
>
> Yes, but probably you will want to avoid plists.
>



  reply	other threads:[~2010-12-06 15:41 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-05 20:15 How to remove verbosity from the data passing mechanism using alist or plist ? Fren Zeee
2010-12-06 14:13 ` Thien-Thi Nguyen
2010-12-06 15:41   ` Fren Zeee [this message]
2010-12-07 14:18     ` Thien-Thi Nguyen
2010-12-07 17:10       ` Fren Zeee
2010-12-06 19:45   ` Fren Zeee
2010-12-06 19:46     ` Fren Zeee
2010-12-07  6:18     ` Fwd: " Fren Zeee
2010-12-07  7:59       ` PJ Weisberg
2010-12-07 15:14         ` Drew Adams
2010-12-07 16:55           ` PJ Weisberg
2010-12-07 17:14       ` Fwd: " Stefan Monnier
2010-12-07 21:24         ` Fren Zeee
2010-12-07 21:27           ` Fwd: " Fren Zeee
2010-12-07 21:48           ` Chad Brown
2010-12-07 23:08             ` Fren Zeee
2010-12-07 23:19               ` Fren Zeee
2010-12-08 16:39                 ` Chong Yidong
2010-12-09  2:30                   ` Fren Zeee
2010-12-08  4:59               ` PJ Weisberg
2010-12-09  4:31           ` Fwd: " Stefan Monnier
2010-12-09 20:33             ` Fren Zeee
2010-12-10  6:59               ` PJ Weisberg
2010-12-10  7:18                 ` joakim
2010-12-10 17:51                   ` Fren Zeee
2010-12-10 17:50                 ` Fren Zeee
     [not found]                   ` <87lj3xrqz1.fsf@uwakimon.sk.tsukuba.ac.jp>
2010-12-12 20:55                     ` Fren Zeee
2010-12-13  4:39                       ` Miles Bader
2010-12-13 19:57                         ` Fren Zeee
2010-12-13 19:58                           ` Fren Zeee
2010-12-13 20:28                           ` Jay Belanger
2010-12-13 20:45                           ` David Kastrup
2010-12-14  0:13                             ` Fren Zeee
2010-12-14  1:20                               ` Fren Zeee
2010-12-07 14:09     ` Thien-Thi Nguyen
2010-12-07 17:11       ` Fren Zeee
2010-12-07 21:10         ` PJ Weisberg
2010-12-08  1:26   ` Fren Zeee
     [not found] <dd1e2214-a914-45ea-a665-fead1ad2928b@39g2000yqa.googlegroups.com>
2010-12-06  5:09 ` Fren Zeee

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=AANLkTik0B6kVH57GuKLsRxO0ks6XB_C4VVxqBVK40gBJ@mail.gmail.com \
    --to=frenzeee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=ttn@gnuvola.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 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.