Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
macro
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Haris  
View profile  
 More options Feb 12 2011, 8:06 am
Newsgroups: comp.lang.lisp
From: "Haris" <fbogdano...@xnet.hr>
Date: Sat, 12 Feb 2011 14:06:11 +0100
Local: Sat, Feb 12 2011 8:06 am
Subject: macro
Hi.

How to repeat this piece of code with a macro:

,@(if (/= (length (parameter "ime")) 0) (list 'ime (parameter "ime"))  (list
'ime :null))

while 'ime and "ime" changes while repeating.

That's already a part of a "sql-compile" macro, like this:

(sql-compile `(:insert-into 'kupci :set
,@(if (/= (length (parameter "ime")) 0) (list 'ime (parameter "ime"))  (list
'ime :null))
,@(if (/= (length (parameter "prezime")) 0) (list 'prezime (parameter
"prezime")) (list 'prezime
and so on.

I should be able to call it like: (a-macro 'ime 'prezime ...)

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Feb 12 2011, 8:26 am
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Sat, 12 Feb 2011 14:26:24 +0100
Local: Sat, Feb 12 2011 8:26 am
Subject: Re: macro

"Haris" <fbogdano...@xnet.hr> writes:
> How to repeat this piece of code with a macro:

> ,@(if (/= (length (parameter "ime")) 0) (list 'ime (parameter "ime"))
> (list 'ime :null))

Hard to say, since this is NOT a piece of code.

,@ outside of ` is meaningless.

> while 'ime and "ime" changes while repeating.

> That's already a part of a "sql-compile" macro, like this:

> (sql-compile `(:insert-into 'kupci :set
> ,@(if (/= (length (parameter "ime")) 0) (list 'ime (parameter "ime"))
> (list 'ime :null))
> ,@(if (/= (length (parameter "prezime")) 0) (list 'prezime (parameter
> "prezime")) (list 'prezime
> and so on.

> I should be able to call it like: (a-macro 'ime 'prezime ...)

I can't see any reason why it should be a macro.

(defun generate-sql-set (parameter)
  (let* ((name  (string parameter))
         (value (parameter name)))
    (list parameter
          (if (zerop (length value))
              :null
              value))))

(defun generate-sql-sets (parameters)
  (reduce (function append) parameters
          :key (function generate-sql-set)
          :from-end t))

(sql-compile `(:insert-into 'kupci :set ,(generate-sql-sets '(ime prezime))))

--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »