From: Thomas Guettler
Subject: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <3D29819C.6090701@thomas-guettler.de>
Hi!

I am new to Lisp and need to change some lines of code
in an Allegro-Lisp 3.0.2 application.

This works:
            (make-menu-item
             :title (mstr :st_391)
             :value
             #'(lambda ()
                 (men-fn-help-2))
             :available-p nil
             )

But if i put "available-p" up it does not work anymore:

            (make-menu-item
             :title (mstr :st_391)
             :value
             :available-p nil
             #'(lambda ()
                 (men-fn-help-2))
             )

and I get this error message:

"Error: Unrecognized keyword NIL supplied to MAKE-MENU-ITEM."

Has someone a hint?

  thomas

From: Joe Marshall
Subject: Re: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <tBfW8.279168$R61.134439@rwcrnsc52.ops.asp.att.net>
"Thomas Guettler" <···········@thomas-guettler.de> wrote in message
·····················@thomas-guettler.de...
> Hi!
>
> I am new to Lisp and need to change some lines of code
> in an Allegro-Lisp 3.0.2 application.
>
> This works:
>             (make-menu-item
>              :title (mstr :st_391)
>              :value
>              #'(lambda ()
>                  (men-fn-help-2))
>              :available-p nil
>              )
>
> But if i put "available-p" up it does not work anymore:
>
>             (make-menu-item
>              :title (mstr :st_391)
>              :value
>              :available-p nil
>              #'(lambda ()
>                  (men-fn-help-2))
>              )
>
> and I get this error message:
>
> "Error: Unrecognized keyword NIL supplied to MAKE-MENU-ITEM."
>
> Has someone a hint?

Keywords are paired.  You ought to be able to do this:

(make-menu-item
   :title (mstr :st_391)
   :available-p nil
   :value #'(lambda ()
              (men-fn-help-2))
   )
From: Thomas Guettler
Subject: Re: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <3D2987B8.3000106@thomas-guettler.de>
Joe Marshall wrote:

> "Thomas Guettler" <···········@thomas-guettler.de> wrote in message
> ·····················@thomas-guettler.de...


[cut]


> Keywords are paired.  You ought to be able to do this:
> 
> (make-menu-item
>    :title (mstr :st_391)
>    :available-p nil
>    :value #'(lambda ()
>               (men-fn-help-2))
>    )


Thank you!

   thomas
From: Thomas Guettler
Subject: Re: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <3D29984B.8070904@thomas-guettler.de>
> Keywords are paired.  You ought to be able to do this:
> 
> (make-menu-item
>    :title (mstr :st_391)
>    :available-p nil
>    :value #'(lambda ()
>               (men-fn-help-2))
>    )

If keywords are paired, what does this mean?:

          (make-menu-item
           :name :file-menu
           :title "Bewertungs~fall"

is "file-menu" the value for "name"?

What is the meaning of ":" before "file-menu"?

Sorry, I am a newbie to lisp

thomas
From: Joe Marshall
Subject: Re: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <SZgW8.280025$R61.134746@rwcrnsc52.ops.asp.att.net>
"Thomas Guettler" <···········@thomas-guettler.de> wrote in message
·····················@thomas-guettler.de...
>
> > Keywords are paired.  You ought to be able to do this:
> >
> > (make-menu-item
> >    :title (mstr :st_391)
> >    :available-p nil
> >    :value #'(lambda ()
> >               (men-fn-help-2))
> >    )
>
> If keywords are paired, what does this mean?:
>
>           (make-menu-item
>            :name :file-menu
>            :title "Bewertungs~fall"
>
> is "file-menu" the value for "name"?

Yes.  The value of NAME is itself a keyword.

> What is the meaning of ":" before "file-menu"?

It really means that the symbol `file-menu' will be interned
in the keyword package.  The keyword package is special in that
every symbol in it automatically has itself as it's own value
(so you don't have to quote keywords).  Otherwise, they are
ordinary symbols.

The pairing up is done by the function.  When you define a
function taking keyword arguments, that function will expect
alternating keyword and value arguments.  The value can be
anything including another keyword, so if you omit a value,
the next keyword will be used as the value and the argument
parsing gets out of sync.
From: Edi Weitz
Subject: Re: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <87wus671pw.fsf@bird.agharta.de>
Thomas Guettler <···········@thomas-guettler.de> writes:

> > Keywords are paired.  You ought to be able to do this:
> > (make-menu-item
> >    :title (mstr :st_391)
> >    :available-p nil
> >    :value #'(lambda ()
> >               (men-fn-help-2))
> >    )
> 
> If keywords are paired, what does this mean?:
> 
>           (make-menu-item
>            :name :file-menu
>            :title "Bewertungs~fall"
> 
> is "file-menu" the value for "name"?

Most likely this is the case, but it doesn't have to. Symbols starting
with a colon always belong to the KEYWORD package and they are
self-evaluating, i.e. they don't have to be quoted.

If a function takes keyword arguments, these arguments have to be
introduced by keyword symbols (like :TITLE in your example). But not
vice-versa: If you see a symbol from the KEYWORD package in a function
call you cannot deduce that it's used to introduce a keyword
argument. See examples below.

Edi.



CL-USER 15 > (describe 'foo)
FOO is a SYMBOL
NAME          "FOO"
VALUE         #<unbound value>
FUNCTION      #<unbound function>
PLIST         (PKG::SYMBOL-NAME-STRING "FOO")
PACKAGE       #<PACKAGE COMMON-LISP-USER>

CL-USER 16 > (describe 'cl-user::foo)
FOO is a SYMBOL
NAME          "FOO"
VALUE         #<unbound value>
FUNCTION      #<unbound function>
PLIST         (PKG::SYMBOL-NAME-STRING "FOO")
PACKAGE       #<PACKAGE COMMON-LISP-USER>

CL-USER 17 > (describe ':foo)
:FOO is a SYMBOL
NAME          "FOO"
VALUE         :FOO
FUNCTION      #<unbound function>
PLIST         (PKG::SYMBOL-NAME-STRING "FOO")
PACKAGE       #<PACKAGE KEYWORD>

CL-USER 18 > (describe :foo)
:FOO is a SYMBOL
NAME          "FOO"
VALUE         :FOO
FUNCTION      #<unbound function>
PLIST         (PKG::SYMBOL-NAME-STRING "FOO")
PACKAGE       #<PACKAGE KEYWORD>

CL-USER 19 > (describe 'keyword:foo)
:FOO is a SYMBOL
NAME          "FOO"
VALUE         :FOO
FUNCTION      #<unbound function>
PLIST         (PKG::SYMBOL-NAME-STRING "FOO")
PACKAGE       #<PACKAGE KEYWORD>

CL-USER 20 > (defun foo (a b &key c) (list a b c))
FOO

CL-USER 21 > (foo 3 4)
(3 4 NIL)

CL-USER 22 > (foo 3 4 :c 6)
(3 4 6)

CL-USER 23 > (foo :x :y :c 6)
(:X :Y 6)
From: Joe Marshall
Subject: Re: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <ihhW8.272802$nZ3.125411@rwcrnsc53>
"Edi Weitz" <···@agharta.de> wrote in message ···················@bird.agharta.de...
>
> If a function takes keyword arguments, these arguments have to be
> introduced by keyword symbols (like :TITLE in your example). But not
> vice-versa: If you see a symbol from the KEYWORD package in a function
> call you cannot deduce that it's used to introduce a keyword
> argument.

You *can* use regular symbols for keywords, but it is discouraged.
Here is a deliberately confusing example:

(defun perverse (a b &key ((foo c)) ((nil d)))
   (list a b c d))

(defun truly-evil-function ()
   (perverse 1
             :name 'foo
             :value nil   '; *MUST* initialize to nil
             |# "old default value" #|))
From: Edi Weitz
Subject: Re: Allegro: Unrecognized keyword NIL
Date: 
Message-ID: <87sn2u70m5.fsf@bird.agharta.de>
"Joe Marshall" <·············@attbi.com> writes:

> "Edi Weitz" <···@agharta.de> wrote in message
> ···················@bird.agharta.de...
> >
> > If a function takes keyword arguments, these arguments have to be
> > introduced by keyword symbols (like :TITLE in your example). But
> > not vice-versa: If you see a symbol from the KEYWORD package in a
> > function call you cannot deduce that it's used to introduce a
> > keyword argument.
> 
> You *can* use regular symbols for keywords, but it is discouraged.
> Here is a deliberately confusing example:
> 
> (defun perverse (a b &key ((foo c)) ((nil d)))
>    (list a b c d))
> 
> (defun truly-evil-function ()
>    (perverse 1
>              :name 'foo
>              :value nil   '; *MUST* initialize to nil
>              |# "old default value" #|))

Oh, yes, thanks for correcting me. I remember I read that once and
immediately forgot about it... :)

Sorry for the confusion,
Edi.