DEFGENERIC with DECLARE statements?

Discussion of Common Lisp
Post Reply
MurderThyLamb
Posts: 2
Joined: Thu Apr 10, 2014 7:01 pm

DEFGENERIC with DECLARE statements?

Post by MurderThyLamb » Thu Apr 10, 2014 7:07 pm

I was looking through some of the code for Open Genera, and I came across something I've never seen before:

Code: Select all

(defgeneric console-function-keys-enabled (console)
  (declare (values (or boolean (list character)))))
(defgeneric console-function-key-enabled-p (console &optional ch)
  (declare (values enabled)))
(defgeneric console-select-keys-enabled (console)
  (declare (values (or boolean (list character)))))
(defgeneric console-select-key-enabled-p (console &optional ch)
  (declare (values enabled)))
(defgeneric console-system-menu-enabled (console)
  (declare (values enabled)))
I compiled these and they work just fine, but I am completely unsure of what the effect is. Can anyone tell me how these particular DECLARE statements work inside of a DEFGENERIC?

Goheeca
Posts: 271
Joined: Thu May 10, 2012 12:54 pm
Contact:

Re: DEFGENERIC with DECLARE statements?

Post by Goheeca » Sat Apr 12, 2014 4:36 am

The standard admits only an optimize clause in defgeneric. And of course, the implementation-dependent clauses. It certainly isn't a standard clause.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

edgar-rft
Posts: 226
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: DEFGENERIC with DECLARE statements?

Post by edgar-rft » Sat Apr 12, 2014 5:37 am

Genera originally was written in Lisp Machine Lisp, where the Lisp Machine Manual, Section 3.5 Declarations says:
Lisp Machine Manual wrote:(values . values) or (:return-list . values)
Records values as the return values list of the function, to be used if anyone asks what values it returns. This is purely documentation.

MurderThyLamb
Posts: 2
Joined: Thu Apr 10, 2014 7:01 pm

Re: DEFGENERIC with DECLARE statements?

Post by MurderThyLamb » Mon Apr 14, 2014 11:47 pm

Thank you, that certainly cleared it up. The fact that it still compiles in Common Lisp (at least Clozure CL) is interesting, I'll have to check for any side effects. Could be slightly useful for documentation, like you pointed out.

macrolyte
Posts: 40
Joined: Sat Jan 25, 2014 8:56 pm
Location: The wilderness of North America

Re: DEFGENERIC with DECLARE statements?

Post by macrolyte » Thu Apr 17, 2014 11:26 am

Open Genera Documentation :=>Here.

Post Reply