License: Public Domain , Load it with Quicklisp: (ql:quickload "simple-guess")
Library type: Protocol , Project complexity: Simple

simple-guess defines a simple extensible protocol for computing a guess using advisors.


I'm using this in an upcoming library to automatically determine the correct metaclass to use by analyzing the defclass form (after a trivial bit of package-local configuration).


Dictionary » simple-guess

Package simple-guess


One should normally import a single symbol from this package, inquire.
Any other symbols from this package should normally be explicitly qualified, such as simple-guess:eager-advisor.
Don't (:use)!

Dictionary » Core

Dictionary » Core » manager

Class simple-guess:manager


The manager basically represents the type of inquiry, and is normally passed directly as the manager to any subinquiries.

The manager is usually stateless, in which case it can be reused across top-level inquiries.

Alternatively, the manager could manage some global state for the top-level inquiry.

Dictionary » Core » advisor

Class simple-guess:advisor


An advisor is an object that returns advice (an object) given a query (a plist), or nil if the advisor has no particular opinion.

Dictionary » Core » inquire

Generic Function inquire

manager advisor &rest query &key &allow-other-keys => advice

Arguments and Values


The advisor ponders query and returns advice to the best of its knowledge, or nil if it doesn't have a particular opinion. (Use fakenil if you need to represent nil as advice.)

The advisor is free to compute its advice any way it likes, including querying subadvisors (using the same query, an amended query, or an unrelated query) and combining their results in some way.


Dictionary » Advisors

Dictionary » Advisors » advisor-mixin

Dictionary » Advisors » advisor

Generic Function simple-guess:advisor

object => advisor


Returns the advisor associated with the object, which is usually an "inner" advisor that is being consulted by the object, the "outer" advisor. A method is defined for simple-guess:advisor-mixin.

Dictionary » Advisors » advisors-mixin

Class simple-guess:advisors-mixin



((advisors :initarg :advisors
           :reader simple-guess:advisors
           :type list
           :documentation ":advisors is required."))

Dictionary » Advisors » advisors

Generic Function simple-guess:advisor

object => advisor


Returns the advisors associated with the object, which are usually "inner" advisors that are being consulted by the object, the "outer" advisor. A method is defined for simple-guess:advisors-mixin.

Dictionary » Advisors » *make-advisor-function*

Variable simple-guess:*make-advisor-function*


A function designator. The initial value is the function make-instance.

As an example, you could bind this variable to a function that forwards to make-instance, but returns the simple-guess:expansion directly if the result was an instance of simple-guess:macro-variant. This would result in slightly increased query performance, at the cost of somewhat decreased debuggability.

Another use-case would be implementing various memoizing schemes, notably for simple-guess:constant-advisors.

Dictionary » Advisors » make-advisor

Dictionary » Advisors » constant-advisor

Dictionary » Advisors » advice

Generic Function simple-guess:advice

advisor => advice


Returns the advisor's advice. A method is defined for simple-guess:constant-advisor.

Dictionary » Advisors » eager-advisor

Dictionary » Advisors » query-variant-advisor

Dictionary » Advisors » query-transformer

Generic Function simple-guess:query-transformer

advisor => query-transformer


Returns the query-transformer that the advisor will funcall with the query before passing it to the inner advisor. A method is defined for simple-guess:query-variant-advisor.

Dictionary » Advisors » Macros

... » Advisors » Macros » macro-advisor

... » Advisors » Macros » expansion

Generic Function simple-guess:expansion

macro-advisor => expansion


Returns the expansion, which is an simple-guess:advisor that implements the semantics of the macro. Substituting the expansion for the macro-advisor must have equivalent semantics, else the consequences are undefined.

... » Advisors » Macros » standard-macro-advisor

... » Advisors » Macros » compute-expansion

Generic Function simple-guess:compute-expansion

macro-advisor => expansion

Arguments and Values


Computes the expansion that will subsequently be returned when calling simple-guess:expansion on macro-advisor.


... » Advisors » Macros » query-variants-advisor

... » Advisors » Macros » query-transformers

... » Advisors » Macros » grouping-function

Returns the function designator that will be applied to the simple-guess:query-transformers to group them. A method is defined for simple-guess:query-variants-advisor.