[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

what is the * type

Jim Newton

1/15/2016 1:45:00 PM

SBCL has a type named CL:*
But I don't see this in the cl spec.

(SB-EXT:VALID-TYPE-SPECIFIER-P 'cl:*)
-> T

But when I try to use this type specifier the following happens.
Can someone give me a clue what is happening?

(typep 3 'cl:*)
VALUES type illegal in this context:
*
[Condition of type SIMPLE-ERROR]

Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1012F60003}>)

Backtrace:
0: (SB-KERNEL::SPECIFIER-TYPE-R (* . T) *)
1: (SB-KERNEL:SPECIFIER-TYPE *)
2: (TYPEP 3 * #<unused argument>)
3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (TYPEP 3 (QUOTE *)) #<NULL-LEXENV>)
4: (EVAL (TYPEP 3 (QUOTE *)))
--more--
26 Answers

Siebe de Vos

1/15/2016 2:31:00 PM

0

Check the type array: while * is not a type-specifier as such, it can be
used in the syntactical position of a type.

S.

On 2016-01-15 14:45, Jim Newton wrote:
> SBCL has a type named CL:*
> But I don't see this in the cl spec.
>
> (SB-EXT:VALID-TYPE-SPECIFIER-P 'cl:*)
> -> T
>
> But when I try to use this type specifier the following happens.
> Can someone give me a clue what is happening?
>
> (typep 3 'cl:*)
> VALUES type illegal in this context:
> *
> [Condition of type SIMPLE-ERROR]
>
> Restarts:
> 0: [RETRY] Retry SLIME REPL evaluation request.
> 1: [*ABORT] Return to SLIME's top level.
> 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1012F60003}>)
>
> Backtrace:
> 0: (SB-KERNEL::SPECIFIER-TYPE-R (* . T) *)
> 1: (SB-KERNEL:SPECIFIER-TYPE *)
> 2: (TYPEP 3 * #<unused argument>)
> 3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (TYPEP 3 (QUOTE *)) #<NULL-LEXENV>)
> 4: (EVAL (TYPEP 3 (QUOTE *)))
> --more--
>

Jim Newton

1/15/2016 3:51:00 PM

0

On Friday, January 15, 2016 at 3:31:17 PM UTC+1, Siebe de Vos wrote:
> Check the type array: while * is not a type-specifier as such, it can be
> used in the syntactical position of a type.
>
> S.

So I think sb-ext:valid-type-specifier-p returns the wrong value.
Which also means that my suggested implementation of valid-type-p is consequently wrong.

(defun valid-type-p (type-designator)
#+sbcl (SB-EXT:VALID-TYPE-SPECIFIER-P type-designator) ;; TODO also exclude cl:*
#+(or clisp allegro) (ignore-errors (subtypep type-designator t))
#-(or sbcl clisp allegro) (error "VALID-TYEP-P not implemented for ~A" (lisp-implementation-type))
)

taruss

1/15/2016 8:37:00 PM

0

On Friday, January 15, 2016 at 7:51:10 AM UTC-8, Jim Newton wrote:
> On Friday, January 15, 2016 at 3:31:17 PM UTC+1, Siebe de Vos wrote:
> > Check the type array: while * is not a type-specifier as such, it can be
> > used in the syntactical position of a type.
> >
> > S.
>
> So I think sb-ext:valid-type-specifier-p returns the wrong value.
> Which also means that my suggested implementation of valid-type-p is consequently wrong.
>
> (defun valid-type-p (type-designator)
> #+sbcl (SB-EXT:VALID-TYPE-SPECIFIER-P type-designator) ;; TODO also exclude cl:*
> #+(or clisp allegro) (ignore-errors (subtypep type-designator t))
> #-(or sbcl clisp allegro) (error "VALID-TYEP-P not implemented for ~A" (lisp-implementation-type))
> )

At some point it may be simpler for you to just implement your own type
inference system rather than trying to make the built-in one from CL work
as you wish.

evw@infometrics.nl

1/16/2016 1:27:00 PM

0

Op vrijdag 15 januari 2016 16:51:10 UTC+1 schreef Jim Newton:
> On Friday, January 15, 2016 at 3:31:17 PM UTC+1, Siebe de Vos wrote:
> > Check the type array: while * is not a type-specifier as such, it can be
> > used in the syntactical position of a type.
> >
> > S.
>
> So I think sb-ext:valid-type-specifier-p returns the wrong value.
> Which also means that my suggested implementation of valid-type-p is consequently wrong.
>
> (defun valid-type-p (type-designator)
> #+sbcl (SB-EXT:VALID-TYPE-SPECIFIER-P type-designator) ;; TODO also exclude cl:*
> #+(or clisp allegro) (ignore-errors (subtypep type-designator t))
> #-(or sbcl clisp allegro) (error "VALID-TYEP-P not implemented for ~A" (lisp-implementation-type))
> )

Dear Jim,

Since about a week or so, I use the following code to find out if a form represents a type:

(defun typenamep (x)
"(typenamep x)
T if <x> is a typename, NIL if it is not."
(cond ((eq x 't) (values t t))
((or (typep x 'symbol) (typep x '(cons symbol)))
(handler-case ; handle incomplete typenames
(multiple-value-bind (subtype? sure?) (subtypep x 'atom)
(if (and subtype? sure?)
(values subtype? sure?)
(subtypep x 'sequence)))
;; incomplete type names are definitely not typenamep
(error () (values nil t))))
(t ; exclude 'function or 'values in (car x)? CLtL2, p.96
(values nil t))))

It is portable and has done its job so far, maybe you can use it as well :)

Kind regards,
Ernst

Marco Antoniotti

1/17/2016 10:18:00 AM

0

On Saturday, January 16, 2016 at 2:27:01 PM UTC+1, Ernst van Waning wrote:
> Op vrijdag 15 januari 2016 16:51:10 UTC+1 schreef Jim Newton:
> > On Friday, January 15, 2016 at 3:31:17 PM UTC+1, Siebe de Vos wrote:
> > > Check the type array: while * is not a type-specifier as such, it can be
> > > used in the syntactical position of a type.
> > >
> > > S.
> >
> > So I think sb-ext:valid-type-specifier-p returns the wrong value.
> > Which also means that my suggested implementation of valid-type-p is consequently wrong.
> >
> > (defun valid-type-p (type-designator)
> > #+sbcl (SB-EXT:VALID-TYPE-SPECIFIER-P type-designator) ;; TODO also exclude cl:*
> > #+(or clisp allegro) (ignore-errors (subtypep type-designator t))
> > #-(or sbcl clisp allegro) (error "VALID-TYEP-P not implemented for ~A" (lisp-implementation-type))
> > )
>
> Dear Jim,
>
> Since about a week or so, I use the following code to find out if a form represents a type:
>
> (defun typenamep (x)
> "(typenamep x)
> T if <x> is a typename, NIL if it is not."
> (cond ((eq x 't) (values t t))
> ((or (typep x 'symbol) (typep x '(cons symbol)))
> (handler-case ; handle incomplete typenames
> (multiple-value-bind (subtype? sure?) (subtypep x 'atom)
> (if (and subtype? sure?)
> (values subtype? sure?)
> (subtypep x 'sequence)))
> ;; incomplete type names are definitely not typenamep
> (error () (values nil t))))
> (t ; exclude 'function or 'values in (car x)? CLtL2, p.96
> (values nil t))))
>
> It is portable and has done its job so far, maybe you can use it as well :)
>
> Kind regards,
> Ernst

Nope. It is not portable, or, at a minimum consistent.

LW > (typenamep (gensym))
NIL
T

CCL> (typenamep (gensym))
T
T

Which is the case that raised this all issue.

IMHO, CCL, CMUCL and SBCL and others need to fix the behavior of (SUBTYPEP (GENSYM) T) in order have a portable version...

Cheers
--
MA

evw@infometrics.nl

1/17/2016 2:56:00 PM

0

Op zondag 17 januari 2016 11:18:25 UTC+1 schreef Marco Antoniotti:
> On Saturday, January 16, 2016 at 2:27:01 PM UTC+1, Ernst van Waning wrote:
> > Op vrijdag 15 januari 2016 16:51:10 UTC+1 schreef Jim Newton:
> > > On Friday, January 15, 2016 at 3:31:17 PM UTC+1, Siebe de Vos wrote:
> > > > Check the type array: while * is not a type-specifier as such, it can be
> > > > used in the syntactical position of a type.
> > > >
> > > > S.
> > >
> > > So I think sb-ext:valid-type-specifier-p returns the wrong value.
> > > Which also means that my suggested implementation of valid-type-p is consequently wrong.
> > >
> > > (defun valid-type-p (type-designator)
> > > #+sbcl (SB-EXT:VALID-TYPE-SPECIFIER-P type-designator) ;; TODO also exclude cl:*
> > > #+(or clisp allegro) (ignore-errors (subtypep type-designator t))
> > > #-(or sbcl clisp allegro) (error "VALID-TYEP-P not implemented for ~A" (lisp-implementation-type))
> > > )
> >
> > Dear Jim,
> >
> > Since about a week or so, I use the following code to find out if a form represents a type:
> >
> > (defun typenamep (x)
> > "(typenamep x)
> > T if <x> is a typename, NIL if it is not."
> > (cond ((eq x 't) (values t t))
> > ((or (typep x 'symbol) (typep x '(cons symbol)))
> > (handler-case ; handle incomplete typenames
> > (multiple-value-bind (subtype? sure?) (subtypep x 'atom)
> > (if (and subtype? sure?)
> > (values subtype? sure?)
> > (subtypep x 'sequence)))
> > ;; incomplete type names are definitely not typenamep
> > (error () (values nil t))))
> > (t ; exclude 'function or 'values in (car x)? CLtL2, p.96
> > (values nil t))))
> >
> > It is portable and has done its job so far, maybe you can use it as well :)
> >
> > Kind regards,
> > Ernst
>
> Nope. It is not portable, or, at a minimum consistent.
>
> LW > (typenamep (gensym))
> NIL
> T
>
> CCL> (typenamep (gensym))
> T
> T
>
> Which is the case that raised this all issue.
>
> IMHO, CCL, CMUCL and SBCL and others need to fix the behavior of (SUBTYPEP (GENSYM) T) in order have a portable version...
>
> Cheers
> --
> MA

Dear Marco,

Well, portable inthe sense that the code does not depend on #+some-CL-implementation. The values it produces certaily depend on the implementation. Comparing the CLs on my machine:

;; (subtypep (gensym) t) ->
;; clisp-2.49: -------- error - invalid type specification
;; sbcl-1.2.11: ------- t, t
;; ccl-1.11-rc1-r16620: t, t
;; abcl-1.3.2: -------- t, t

IIRC and IIUC, any object in CL belongs to type T, but Clisp does not seem to agree. IIRC and IIUC again, the direct subtypes of T are atom and sequence, so I tried again:

;; (subtypep (gensym) 'atom) ->
;; clisp-2.49: -------- error - invalid type specification
;; sbcl-1.2.11: ------- nil, nil
;; ccl-1.11-rc1-r16620: nil, nil
;; abcl-1.3.2: -------- t, t

;; (subtypep (gensym) 'sequence) ->
;; clisp-2.49: -------- error - invalid type specification
;; sbcl-1.2.11: ------- nil, nil
;; ccl-1.11-rc1-r16620: nil, nil
;; abcl-1.3.2: -------- nil, t

Both sbcl and ccl do not see any symbol as type, abcl differs, does not seem to distinguish a symbol from a typename written as a symbol. Then here is what typenamep produces:

;; (typenamep (gensym)) ->
;; clisp-2.49: -------- nil, t (error exit)
;; sbcl-1.2.11: ------- nil, nil
;; ccl-1.11-rc1-r16620: nil, nil
;; abcl-1.3.2: -------- t, t

A symbol is not (necessarily) an atomic typename. I am not sure why Clisp signals an error in this case.

Kind regards,

Ernst

evw@infometrics.nl

1/17/2016 3:16:00 PM

0

Op zondag 17 januari 2016 11:18:25 UTC+1 schreef Marco Antoniotti:
> On Saturday, January 16, 2016 at 2:27:01 PM UTC+1, Ernst van Waning wrote:
> > Op vrijdag 15 januari 2016 16:51:10 UTC+1 schreef Jim Newton:
> > > On Friday, January 15, 2016 at 3:31:17 PM UTC+1, Siebe de Vos wrote:
> > > > Check the type array: while * is not a type-specifier as such, it can be
> > > > used in the syntactical position of a type.
> > > >
> > > > S.
> > >
> > > So I think sb-ext:valid-type-specifier-p returns the wrong value.
> > > Which also means that my suggested implementation of valid-type-p is consequently wrong.
> > >
> > > (defun valid-type-p (type-designator)
> > > #+sbcl (SB-EXT:VALID-TYPE-SPECIFIER-P type-designator) ;; TODO also exclude cl:*
> > > #+(or clisp allegro) (ignore-errors (subtypep type-designator t))
> > > #-(or sbcl clisp allegro) (error "VALID-TYEP-P not implemented for ~A" (lisp-implementation-type))
> > > )
> >
> > Dear Jim,
> >
> > Since about a week or so, I use the following code to find out if a form represents a type:
> >
> > (defun typenamep (x)
> > "(typenamep x)
> > T if <x> is a typename, NIL if it is not."
> > (cond ((eq x 't) (values t t))
> > ((or (typep x 'symbol) (typep x '(cons symbol)))
> > (handler-case ; handle incomplete typenames
> > (multiple-value-bind (subtype? sure?) (subtypep x 'atom)
> > (if (and subtype? sure?)
> > (values subtype? sure?)
> > (subtypep x 'sequence)))
> > ;; incomplete type names are definitely not typenamep
> > (error () (values nil t))))
> > (t ; exclude 'function or 'values in (car x)? CLtL2, p.96
> > (values nil t))))
> >
> > It is portable and has done its job so far, maybe you can use it as well :)
> >
> > Kind regards,
> > Ernst
>
> Nope. It is not portable, or, at a minimum consistent.
>
> LW > (typenamep (gensym))
> NIL
> T
>
> CCL> (typenamep (gensym))
> T
> T
>
> Which is the case that raised this all issue.
>
> IMHO, CCL, CMUCL and SBCL and others need to fix the behavior of (SUBTYPEP (GENSYM) T) in order have a portable version...
>
> Cheers
> --
> MA

Let me add that LW does a very good jobs here :)

Marco Antoniotti

1/17/2016 4:34:00 PM

0

On Sunday, January 17, 2016 at 4:16:35 PM UTC+1, Ernst van Waning wrote:
> Op zondag 17 januari 2016 11:18:25 UTC+1 schreef Marco Antoniotti:
> > On Saturday, January 16, 2016 at 2:27:01 PM UTC+1, Ernst van Waning wrote:
> > > Op vrijdag 15 januari 2016 16:51:10 UTC+1 schreef Jim Newton:
> > > > On Friday, January 15, 2016 at 3:31:17 PM UTC+1, Siebe de Vos wrote:
> > > > > Check the type array: while * is not a type-specifier as such, it can be
> > > > > used in the syntactical position of a type.
> > > > >
> > > > > S.
> > > >
> > > > So I think sb-ext:valid-type-specifier-p returns the wrong value.
> > > > Which also means that my suggested implementation of valid-type-p is consequently wrong.
> > > >
> > > > (defun valid-type-p (type-designator)
> > > > #+sbcl (SB-EXT:VALID-TYPE-SPECIFIER-P type-designator) ;; TODO also exclude cl:*
> > > > #+(or clisp allegro) (ignore-errors (subtypep type-designator t))
> > > > #-(or sbcl clisp allegro) (error "VALID-TYEP-P not implemented for ~A" (lisp-implementation-type))
> > > > )
> > >
> > > Dear Jim,
> > >
> > > Since about a week or so, I use the following code to find out if a form represents a type:
> > >
> > > (defun typenamep (x)
> > > "(typenamep x)
> > > T if <x> is a typename, NIL if it is not."
> > > (cond ((eq x 't) (values t t))
> > > ((or (typep x 'symbol) (typep x '(cons symbol)))
> > > (handler-case ; handle incomplete typenames
> > > (multiple-value-bind (subtype? sure?) (subtypep x 'atom)
> > > (if (and subtype? sure?)
> > > (values subtype? sure?)
> > > (subtypep x 'sequence)))
> > > ;; incomplete type names are definitely not typenamep
> > > (error () (values nil t))))
> > > (t ; exclude 'function or 'values in (car x)? CLtL2, p.96
> > > (values nil t))))
> > >
> > > It is portable and has done its job so far, maybe you can use it as well :)
> > >
> > > Kind regards,
> > > Ernst
> >
> > Nope. It is not portable, or, at a minimum consistent.
> >
> > LW > (typenamep (gensym))
> > NIL
> > T
> >
> > CCL> (typenamep (gensym))
> > T
> > T
> >
> > Which is the case that raised this all issue.
> >
> > IMHO, CCL, CMUCL and SBCL and others need to fix the behavior of (SUBTYPEP (GENSYM) T) in order have a portable version...
> >
> > Cheers
> > --
> > MA
>
> Let me add that LW does a very good jobs here :)

Ok. I see that I have an older version of SBCL...

MA

Jim Newton

1/18/2016 9:27:00 AM

0


> Dear Jim,
>
> Since about a week or so, I use the following code to find out if a form represents a type:
>
> (defun typenamep (x)
> "(typenamep x)
> T if <x> is a typename, NIL if it is not."
> (cond ((eq x 't) (values t t))
> ((or (typep x 'symbol) (typep x '(cons symbol)))
> (handler-case ; handle incomplete typenames
> (multiple-value-bind (subtype? sure?) (subtypep x 'atom)
> (if (and subtype? sure?)
> (values subtype? sure?)
> (subtypep x 'sequence)))
> ;; incomplete type names are definitely not typenamep
> (error () (values nil t))))
> (t ; exclude 'function or 'values in (car x)? CLtL2, p.96
> (values nil t))))
>


Hi Ernst, thanks for chiming in. One problem I see immediately is that this function raises several conditions which get reported as warnings during compilation (on sbcl anyway). The issue is that
SBCL (maybe others???) raise an unknown-type condition if subtypep is called with an unknown type.
Hmmmm, maybe this is a clue of how to solve the problem.....

(climb::print-conditions (ERNST-TYPENAMEP (gensym)))
Conditions singled while evaluating: ((ERNST-TYPENAMEP (GENSYM)))
1: #<SB-KERNEL:PARSE-UNKNOWN-TYPE {186330E353}>
2: #<SB-KERNEL:PARSE-UNKNOWN-TYPE {186330E513}>
NIL

evw@infometrics.nl

1/18/2016 12:47:00 PM

0

Op maandag 18 januari 2016 10:27:41 UTC+1 schreef Jim Newton:
> > Dear Jim,
> >
> > Since about a week or so, I use the following code to find out if a form represents a type:
> >
> > (defun typenamep (x)
> > "(typenamep x)
> > T if <x> is a typename, NIL if it is not."
> > (cond ((eq x 't) (values t t))
> > ((or (typep x 'symbol) (typep x '(cons symbol)))
> > (handler-case ; handle incomplete typenames
> > (multiple-value-bind (subtype? sure?) (subtypep x 'atom)
> > (if (and subtype? sure?)
> > (values subtype? sure?)
> > (subtypep x 'sequence)))
> > ;; incomplete type names are definitely not typenamep
> > (error () (values nil t))))
> > (t ; exclude 'function or 'values in (car x)? CLtL2, p.96
> > (values nil t))))
> >
>
>
> Hi Ernst, thanks for chiming in. One problem I see immediately is that this function raises several conditions which get reported as warnings during compilation (on sbcl anyway). The issue is that
> SBCL (maybe others???) raise an unknown-type condition if subtypep is called with an unknown type.
> Hmmmm, maybe this is a clue of how to solve the problem.....
>
> (climb::print-conditions (ERNST-TYPENAMEP (gensym)))
> Conditions singled while evaluating: ((ERNST-TYPENAMEP (GENSYM)))
> 1: #<SB-KERNEL:PARSE-UNKNOWN-TYPE {186330E353}>
> 2: #<SB-KERNEL:PARSE-UNKNOWN-TYPE {186330E513}>
> NIL

The CL systems in my previous post do not warn during compilation on my machine. Maybe I have older versions like Marco :)
When running typenamep on arbitrary forms errors may be signaled for unknown types, which are handled. Your print-conditions prints them.

Anyway, I use typenamep to cope with my problems here, I hope it is useful for you as well.