unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Using setq to obtain a symbol from a list, so that I can assign a  function to it
@ 2008-04-22  2:28 srinik001
  2008-04-22  5:19 ` srinik001
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: srinik001 @ 2008-04-22  2:28 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I would really appreciate some help on this. I am trying to do just
about everything with Emacs (and Emacs Lisp) these days. One of the
things I need to do in my job is to create XML files. I thought I
would use Emacs rather than some other editor/tool.

So, I am trying to write a tool that will enable me to write specific
XML files by prompting me to enter values. Here is how I am trying to
do it.

First, I set a variable that will provide a "grammar" for my file that
Emacs will help me write. An example is the following : of course, my
actual problem is not about generating English sentences; this is just
for illustration.

(setq grammar '((sentence <- subject predicate)
		(subject <- article noun)
		(predicate <- verb)))

I expect to generate functions that look like this:

(defun sentence()
  (........some stuff .........)
  (subject)
  (predicate)
  (........some stuff again...))

What I want the system to do is to generate the function
automatically. So, I should have functions for sentence, subject and
predicate. I will of course hand-code the functions for article, noun
and verb.

I don't want to write the above defun; I want to generate it by using
(setq sentence #'(lambda() ( (subject) (predicate)))). Of course,
instead of "sentence". I want to use (car x) or something like that by
reading the variable "grammar".

Here is the problem: when I do this:

(setq (car (expression that generates sentence) #'(lambda() (print
"hello")))

I get an error.

But if I do a (setq x (car ... ) to get the sentence symbol and THEN
assign it, everything works.

Is there something fundamental I am missing?

Thanks,

Regards,

SK




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

end of thread, other threads:[~2008-05-20  2:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-22  2:28 Using setq to obtain a symbol from a list, so that I can assign a function to it srinik001
2008-04-22  5:19 ` srinik001
2008-04-22 12:54   ` Barry Margolin
2008-04-23  4:40     ` srinik001
2008-04-23 22:14       ` Pascal Bourguignon
2008-04-24  2:50       ` Barry Margolin
2008-04-28  1:03         ` srinik001
2008-04-23  5:10   ` Kevin Rodgers
     [not found]   ` <mailman.10729.1208927476.18990.help-gnu-emacs@gnu.org>
2008-05-17 22:14     ` David Combs
2008-05-20  2:42       ` Kevin Rodgers
2008-04-22 15:22 ` Ted Zlatanov
2008-04-22 18:36   ` Pascal Bourguignon
2008-05-17 22:20     ` David Combs
2008-04-22 19:59 ` Pascal Bourguignon
2008-04-23  3:11   ` Timothy Hobbs
     [not found]   ` <mailman.10727.1208920326.18990.help-gnu-emacs@gnu.org>
2008-04-23  4:06     ` Barry Margolin

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