unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: Oleksandr Gavenko <gavenkoa@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: "Backquote constructs" to "splice" values without "eval".
Date: Tue, 08 Jan 2013 11:18:05 +0530	[thread overview]
Message-ID: <87sj6c8bu2.fsf@gmail.com> (raw)
In-Reply-To: <87obh0sm1x.fsf@gavenkoa.example.com> (Oleksandr Gavenko's message of "Mon, 07 Jan 2013 23:47:06 +0200")

Oleksandr Gavenko <gavenkoa@gmail.com> writes:

> On 2013-01-07, Jambunathan K wrote:
>
>>> I also start thinking about "apply" with several list inside it:
>>>
>>>   (apply '+ 1 '(2) '(3 4))
>>>
>>> But above expression fail (only last arg expanded as list of args). To resolve
>>> this issue I use expression:
>>>
>>>   (apply '+ 1 (append '(2) '(3 4)))
>>>
>>> But how about expression with atoms between (??):
>>>
>>>   '(1) 2 '(3 4)
>>>
>>> I write non-linear code:
>>>
>>>   (apply '+ (append '(1) (cons 2 '(3 4))))
>>>
>>> How to avoid call to "cons"?
>>
>> (apply '+ (loop for x in '(1 (2) (3 4))
>> 		collect (if (numberp x) x (apply '+ x))))
>>
>> There are also other predicates that you can use.  For eg., atom, consp,
>> listp.
>
> Your trick work because + is associative operation.
>
> I just start from example from 'apply' doc-string.

It is not clear to me what you are saying.  But I know that people who
are in Agra are searching for Taj Mahal, 99.9% of the cases.  You may
not visit Taj but atleast you can walk around Agra.  One is no better
than the other.

> Consider example when 'some' func return region and 'another' require beg/end
> pair:
>
>   (defun some () ... (list beg end))
>   (defun another (x beg end y) ...)
>
> I think that this code ugly:
>
>   (another x (car (some)) (cdr (some)) y)

Talking about ugly, while architecting something on a small scale is
sure way to get lost.

Aesthetics is over-rated.

ps: This is not a criticism of what you are doing but an observation
from my own experience.

> If 'some' is complicated you need:
>
>   (let* ( (region some) (beg (car region)) (end (cdr region)) )
>       (another x beg end y)
>     )

destructuring-bind, pcase, pcase*
-- 



  reply	other threads:[~2013-01-08  5:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.16855.1357563071.855.help-gnu-emacs@gnu.org>
2013-01-07 15:02 ` "Backquote constructs" to "splice" values without "eval" Barry Margolin
2013-01-07 20:36   ` Oleksandr Gavenko
2013-01-07 21:10     ` Jambunathan K
2013-01-07 21:47       ` Oleksandr Gavenko
2013-01-08  5:48         ` Jambunathan K [this message]
2013-01-08  5:51           ` Jambunathan K
     [not found]   ` <mailman.16874.1357591009.855.help-gnu-emacs@gnu.org>
2013-01-07 20:51     ` Barry Margolin
2013-01-07 12:50 Oleksandr Gavenko

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=87sj6c8bu2.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=gavenkoa@gmail.com \
    --cc=help-gnu-emacs@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.
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).