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
Message from discussion Odd length keyword list
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
 
Matus Kmit  
View profile  
 More options Jan 12 2012, 3:19 am
Newsgroups: comp.lang.lisp
From: Matus Kmit <simply.nit...@gmail.com>
Date: Thu, 12 Jan 2012 00:19:21 -0800 (PST)
Local: Thurs, Jan 12 2012 3:19 am
Subject: Re: Odd length keyword list
On 11 Jan., 18:59, kenny <kentil...@gmail.com> wrote:

> On Jan 11, 10:45 am, Matus Kmit <simply.nit...@gmail.com> wrote:

> > Hi

> > I have this macro:

> > (defmacro format-time (one &optional two &key format-fn)
> >   (let ((one* (eval one))
> >         (two* (eval two)))
> >     (if two*
> >         `(,format-fn t "(~a:~a - ~a:~a)" ,@one* ,@two*)
> >         `(,format-fn t "~a:~a" ,@one*))))

> > If I try to macroexpand it with (macroexpand '(format-time (normalize-
> > consed-time '(1 . 2)) :format-fn format)) I am getting the following
> > error:

> > Odd length keyword list: (FORMAT)
> >    [Condition of type CCL::SIMPLE-PROGRAM-ERROR]

> > What is wrong?

> Answered elsewhere, I presume. Meanwhile, you are pretty much doomed
> trying to make mix optional and keyword params. But macros give you a
> little more control, so you might have done:

>   (defmacro format-time ((one &optional two) &key (format-fn 'format))

> I threw in the default value for format-fn, which you really should
> have.

Thanks all for your help. I got it.

> Supermeanwhile: why is this a macro?

> -hk

More or less an experiment, while being bored at work and messing
aroung with lisp trying to understand macros, eval, parameter types,
etc...

On the other hand I was looking for a way how to splice parameters
which are given in a list inside the format function. The first thing
I could think of was macro, although a syntactic abstraction for this
particular case probably does not make much sense. Meanwhile :-), I
remembered "apply", which seems to do just fine what i need:

(apply #'format t (cons "~a:~a" (normalize-consed-time '(1 . 2))))

greetings,
Matus


 
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.