········@ziplip.com" <·······@ziplip.com> writes:
> Is it possible to see one?
Why?
No, I don't mean to be unhelpful. I honestly believe it is hurtful for yuo
to proceed with learning in this way.
Consider learning about animals by saying:
Could I see a tree of all genetic classes?
There are new ones being made all the time. There may be ones we've never
discovered. It's useful to a certain kind of people who do research in this
area to really be familiar with the full class. For everyone else, it's
better to think there are plants and fish and birds and mammals and bugs,
or some such simplification until you get going, and to learn the parts of
the tree that you need.
The REAL world is not exhaustively enumerable. Any kind of learning that
is based on exhaustive enumeration and pre-knowledge seems to me to be
encouraging a mode of thinking that you don't need.
Learn to backward chain on type (understanding it from its component types)
rather than forward chain (asking what all the instances are of a component
type). That will get you farther.
From: james anderson
Subject: Re: tree of all elementary types
Date:
Message-ID: <3F265601.1DF8C2C5@setf.de>
········@ziplip.com" wrote:
>
> Is it possible to see one?
the question is rather ambiguous, but none the less, there are class graphers
which help one with such things. the isi grapher comes to mind as a portable
instance. google will get you there. if not, your lisp-of-choice/vendor must
have one.
without tooling up, the techniques for basic introspection are
straight-forward, so you can always do something like
(defgeneric print-class-tree (class &key package stream metaclass)
(:method ((class-name symbol)
&key (stream *standard-output*)
(package (symbol-package class-name))
(metaclass t)
&aux (class (find-class class-name nil))
(*print-class-list* nil)
(*print-class-level* 0))
(declare (special *print-class-list* *print-class-level*))
(cond (class
(print-class-tree class :stream stream :package package
:metaclass metaclass))
(t
(terpri stream)
(dotimes (i *print-class-level*) (write-char #\space stream))
(format stream "not found: ~s" class))))
(:method ((class class)
&key (package (symbol-package (class-name class)))
(stream *standard-output*)
(metaclass t)
&aux (name (class-name class)))
(declare (special *print-class-list* *print-class-level*))
(terpri stream)
(dotimes (i *print-class-level*) (write-char #\space stream))
(prin1 name)
(let ((subclasses (remove-if-not #'(lambda (class)
(and
(or (eq package t)
(eq (symbol-package
(class-name class))
package))
(typep class metaclass)))
(class-direct-subclasses class))))
(when subclasses
(cond ((find class *print-class-list*)
(write-string " ..." stream)
)
(t
(push class *print-class-list*)
(let ((*print-class-level* (+ *print-class-level* 1)))
(declare (special *print-class-level*))
(dolist (subclass subclasses)
(print-class-tree subclass :stream stream
:package package)))))))))
which runs in the direction of
? (type-of (find-class t))
BUILT-IN-CLASS
? (print-class-tree 't :metaclass (type-of (find-class t)))
T
PACKAGE
SYMBOL
NULL
KEYWORD
SEQUENCE
VECTOR
STRING
SIMPLE-STRING
SIMPLE-BASE-STRING
BASE-STRING
SIMPLE-BASE-STRING
BIT-VECTOR
SIMPLE-BIT-VECTOR
LIST
NULL
CONS
NUMBER
REAL
RATIONAL
INTEGER
SIGNED-BYTE
UNSIGNED-BYTE
BIGNUM
FIXNUM
BIT
RATIO
FLOAT
SHORT-FLOAT
DOUBLE-FLOAT
COMPLEX
CHARACTER
EXTENDED-CHARACTER
EXTENDED-CHAR
BASE-CHARACTER
BASE-CHAR
STANDARD-CHAR
ARRAY
SIMPLE-ARRAY
VECTOR ...
NIL
?
Your code is elegant, but what it produces is manifestly not a "tree".
It is reentrant, or more specifically, a reentrant acyclic graph.
Obviously you know this, since the code specifically deals with
reentrancies, but it will be useful and instructive for the beginner
to identify the reentrant branches and try to understand why they are
there and what they mean in the language.
james anderson wrote:
> ? (print-class-tree 't :metaclass (type-of (find-class t)))
>
> T
> PACKAGE
> SYMBOL
> NULL
> KEYWORD
> SEQUENCE
> VECTOR
> STRING
> SIMPLE-STRING
> SIMPLE-BASE-STRING
> BASE-STRING
> SIMPLE-BASE-STRING
> BIT-VECTOR
> SIMPLE-BIT-VECTOR
> LIST
> NULL
> CONS
> NUMBER
> REAL
> RATIONAL
> INTEGER
> SIGNED-BYTE
> UNSIGNED-BYTE
> BIGNUM
> FIXNUM
> BIT
> RATIO
> FLOAT
> SHORT-FLOAT
> DOUBLE-FLOAT
> COMPLEX
> CHARACTER
> EXTENDED-CHARACTER
> EXTENDED-CHAR
> BASE-CHARACTER
> BASE-CHAR
> STANDARD-CHAR
> ARRAY
> SIMPLE-ARRAY
> VECTOR ...
> NIL
> ?
From: james anderson
Subject: Re: tree of all elementary types
Date:
Message-ID: <3F27A880.1261AB12@setf.de>
to be honest, i'd gotten by, until now, with the rather sloppy notion, that i
was dealing with a lattice. i suppose, had i been more awake at the time, and
been more certain what the initial post was intending to ask, i might just
have thought "no", and left it at that.
...
"Steven M. Haflich" wrote:
>
> Your code is elegant, but what it produces is manifestly not a "tree".
> It is reentrant, or more specifically, a reentrant acyclic graph.
> Obviously you know this, since the code specifically deals with
> reentrancies, but it will be useful and instructive for the beginner
> to identify the reentrant branches and try to understand why they are
> there and what they mean in the language.
>
> james anderson wrote:
> > ? (print-class-tree 't :metaclass (type-of (find-class t)))
> >
> > T
> > ...f