From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: extracting serial repeats
Date: Sun, 24 Jan 2010 12:42:11 +0100 [thread overview]
Message-ID: <4B5C3213.6050807@easy-emacs.de> (raw)
In-Reply-To: <87wrz724f0.wl%anselm.helbig+news2009@googlemail.com>
Anselm Helbig wrote:
> Hi Andreas!
>
>
>> thanks a lot.
>>
>> Seems I didn't describe the problem well: it's something like: "How to
>> avoid parallel implementing?".
>> Or let's say it that way:
>>
>> Given a serial or serials of lambda-forms which take arguments of the
>> same kind processing it the same way,
>> but differ in function-names, they are referring to.
>>
>> Instead of implementing the same forms repeatedly under different names,
>> we could re-use one.
>>
>
> So you don't like the macro approach because it's still creating a lot
> of functions internally? If you'd like to share the implementation,
> the code could look like this:
>
> (defun foo (n a b c)
> (message "n: %d; a: %s; b: %s; c: %s" n a b c))
>
> (defun make-foo-function (n)
> (lexical-let ((lexical-n n))
> (lambda (a b c)
> (foo lexical-n a b c))))
>
> (dotimes (i 22)
> (fset (intern (format "foo-function-%d" i))
> (make-foo-function i)))
>
> (foo-function-21 1 2 3)
>
> I there's anything unclear about this code or the defmacro-approach I
> gave you before, just ask.
>
>
>> Can do that by hand, sure. But as the issue shows up occasionaly, a tool
>> doing these extractions might be useful.
>>
>
> Maybe I didn't get the issue right: you've got repetetive code to
> start with and want to have it refactored automatically?
yes
> It's
> certainly possible to have such functionality, on the other hand, you
> don't have to write repetetive code in lisp in the first place,
yes, rather avoid it. The scenario is: it just happened.
Precisely while writing some tests.
Wrote one form testing a patch,
another form testing another patch,
then remarked the parallels...
Thanks again
Andreas
> that's
> what macros are for. And, as shown above, you can also use functional
> programming techniques to the same end.
>
> All the best,
>
> Anselm
>
>
>
next prev parent reply other threads:[~2010-01-24 11:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.74.1264262438.14305.help-gnu-emacs@gnu.org>
2010-01-23 20:00 ` extracting serial repeats Anselm Helbig
2010-01-24 9:14 ` Andreas Röhler
[not found] ` <mailman.95.1264324380.14305.help-gnu-emacs@gnu.org>
2010-01-24 10:17 ` Anselm Helbig
2010-01-24 11:42 ` Andreas Röhler [this message]
2010-01-23 16:01 Andreas Roehler
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=4B5C3213.6050807@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--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.
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.