unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to remove verbosity from the data passing mechanism using alist or plist ?
@ 2010-12-05 20:15 Fren Zeee
       [not found] ` <87lj43at0i.fsf@ambire.localdomain>
  0 siblings, 1 reply; 23+ messages in thread
From: Fren Zeee @ 2010-12-05 20:15 UTC (permalink / raw)
  To: Emacs Dev [emacs-devel]

Reading thru the various threads and replies by the luminaries of
lisp, CL, elisp, scheme,
functional programming etc.

I have decided to write a small game of following data in a buffer. At
this state I am only
readyfor the following questions. Yesterday, in my questions, I
explored how to get data
from buffer into strings.


8<-----------------------------------------------------------------------------------------------------------------



GOLD=1000

(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 file, find GOLD
      ;;
      (goto-char (point-max))
     ; Go to the end of the file, and then
      (search-backward-regexp "GOLD=\\([0-9]+\\)\n" nil nil nil)
     ;  find the GOLD, and
      (list
     ;  as an a-list, return its
       (list
	:GOLD-value                                                         ;
 value, and
	(string-to-number                                                   ;
 read and return it, with its
	 (replace-regexp-in-string "GOLD=\\([0-9]+\\)\n" "\\1"  (match-string 0))))
       (list
	:GOLD-location                                                      ;
 location.
	(point) )))))


; (assoc-default :GOLD-value (find-my-marker-GOLD))


(defun test-GOLD (GOLD)
  "for now, tests the alist passing mechanism, later more."
  (let ((GOLD-value    (car (assoc-default :GOLD-value    GOLD )))
	(GOLD-location (car (assoc-default :GOLD-location GOLD ))))
    (list GOLD-value GOLD-location)
    )
  )

(test-GOLD (find-my-marker-GOLD))
8<-----------------------------------------------------------------------------------------------------------------

[Q] Are there any defects in this method of passing struct and what
improvements are possible ?

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

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

[Q] Is there a way to using plists for return from find-my-marker-GOLD
    and utilize in the user function test-GOLD

[Q] As you can see, I am looking for several level of solutions so I
can weight them.
    The main goal is brevity, style improvement and more acceptable style.

 (a) Solution that is pure elisp and does not use any defmacros , defclass etc.
 (b) Solution that is clisp and un-restricted.
   (c) and within both of the above, solutions with plist and alist.

[Q] test-GOLD will actually be a function called find-GOLD-processing-plant

    similar to find-my-marker-GOLD in
    that it would go using this data to the nearest GOLD processing plant with
    the help of a suitable regexp. There was no need to split this set
of actions
    into several small functions except for the purpose of modularity. The issue
    is what is a good style for such a problem where there is coupling ie only
    find-GOLD-processing-plant can use the object of type GOLD, not a
    find-SILVER-processing-plant because there are some hidden assumptions, such
    as the nearest regexp of type PLANT=address near a GOLD=value object
    is a GOLD processing plant and the nearest regexp of type PLANT=address
    near a SILVER=value object is a SILVER processing plant.

    Thus, in view of this hidden coupling, which I am not able to get rid of
    without too much complication and


The main goals are
                     to write main function as a readable english prose
and also
                     to remove the verbosity in passing data (alist and plist)
                     in and out of functions.

Thanks again for your help.

For a newbie please put some comments as in my function
find-my-marker-GOLD since many of you try to use language constructs
in clever ways ?

Franz Xe



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2010-12-14  1:20 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-05 20:15 How to remove verbosity from the data passing mechanism using alist or plist ? Fren Zeee
     [not found] ` <87lj43at0i.fsf@ambire.localdomain>
     [not found]   ` <AANLkTik5uKm1aZ+u3Z_Hn9Jy17y=Tn94dr6SNP5EVfSY@mail.gmail.com>
2010-12-07  6:18     ` Fwd: " Fren Zeee
2010-12-07 17:14       ` Stefan Monnier
2010-12-07 21:24         ` 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-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

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