This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

DEFGENERIC with DECLARE statements?

5 posts · 5107 views

I was looking through some of the code for Open Genera, and I came across something I've never seen before:
(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?

Re: DEFGENERIC with DECLARE statements?

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.

Re: DEFGENERIC with DECLARE statements?

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.

Re: DEFGENERIC with DECLARE statements?

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.

Re: DEFGENERIC with DECLARE statements?

Open Genera Documentation :=>Here.