From: Pascal Bourguignon
Subject: typecase PATHNAME ?
Date: 
Message-ID: <877jqj25hi.fsf@thalassa.informatimago.com>
* (typecase #P"/tmp/" ((string) :true) (otherwise :false))
:FALSE

* (typecase #P"/tmp/" ((pathname) :true) (otherwise :false))
Error in function COMMON-LISP::%%TYPEP:  Unknown type specifier: (PATHNAME)
in cmucl, and similar errors in sbcl and clisp.

Why PATHNAME is not a known type specified while STRING is?  I don't
see in CLHS any significant difference in this respect between the two
pages specifying both _System_Class_.
 

Note the ludicrous of the current situation:

* (deftype pn () 'pathname)
PN
* (typecase #P"/tmp/" ((pn) :true) (otherwise :false))
:TRUE
* 


I don't think Common-Lisp specifiers had this in mind, am I wrong?


For example, in DEFCLASS:

  Defining a new class also causes a type of the same name to be defined. 

(A class is a type specified and TYPECASE expects types).

So obviously for user defined classes, it should work too, but it doesn't.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.

From: Sam Steingold
Subject: Re: typecase PATHNAME ?
Date: 
Message-ID: <usm97aj5n.fsf@gnu.org>
> * Pascal Bourguignon <····@zbhfr-cbgngb.pbz> [2004-09-24 14:53:13 +0200]:
>
> * (typecase #P"/tmp/" ((string) :true) (otherwise :false))
> :FALSE
>
> * (typecase #P"/tmp/" ((pathname) :true) (otherwise :false))
> Error in function COMMON-LISP::%%TYPEP:  Unknown type specifier: (PATHNAME)
> in cmucl, and similar errors in sbcl and clisp.
>
> Why PATHNAME is not a known type specified while STRING is?

Both PATHNAME and STRING are valid type specifiers,
but, while (STRING) _is_ a valid type specifier, (PATHNAME) is _not_!

(typecase #P"/tmp/" (pathname :true) (otherwise :false))
==> :TRUE

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Those who don't know lisp are destined to reinvent it, poorly.
From: Barry Margolin
Subject: Re: typecase PATHNAME ?
Date: 
Message-ID: <barmar-67B375.19583924092004@comcast.dca.giganews.com>
In article <·············@gnu.org>, Sam Steingold <···@gnu.org> wrote:

> > * Pascal Bourguignon <····@zbhfr-cbgngb.pbz> [2004-09-24 14:53:13 +0200]:
> >
> > * (typecase #P"/tmp/" ((string) :true) (otherwise :false))
> > :FALSE
> >
> > * (typecase #P"/tmp/" ((pathname) :true) (otherwise :false))
> > Error in function COMMON-LISP::%%TYPEP:  Unknown type specifier: (PATHNAME)
> > in cmucl, and similar errors in sbcl and clisp.
> >
> > Why PATHNAME is not a known type specified while STRING is?
> 
> Both PATHNAME and STRING are valid type specifiers,
> but, while (STRING) _is_ a valid type specifier, (PATHNAME) is _not_!

None of the responders have explained *why* STRING can be put in 
parentheses like this.

Some type names accept optional parameters to further restrict the type.  
For instance, INTEGER allows you to specify lower and upper bounds, so 
you can use (INTEGER 0 10) as a type specifier.  But these parameters 
are all optional, so you can also use (INTEGER 0), and (INTEGER) is 
allowed as the natural continuation of this (and it's equivalent to just 
INTEGER).

The STRING type allows you to specify the length of the string, e.g. 
(STRING 5) means a 5-character string.  STRING and (STRING) are 
equivalent to (STRING *), the set of strings of any length.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Thomas A. Russ
Subject: Re: typecase PATHNAME ?
Date: 
Message-ID: <ymibrfrb8hi.fsf@sevak.isi.edu>
Barry Margolin <······@alum.mit.edu> writes:
> 
> None of the responders have explained *why* STRING can be put in 
> parentheses like this.

Thanks, Barry.

I was wondering about that, but was too lazy to look it up myself.

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Juan Jose Garcia Ripoll
Subject: Re: typecase PATHNAME ?
Date: 
Message-ID: <2rikhoF1am58vU1@uni-berlin.de>
Pascal Bourguignon wrote:
> * (typecase #P"/tmp/" ((string) :true) (otherwise :false))
> :FALSE
> 
> * (typecase #P"/tmp/" ((pathname) :true) (otherwise :false))
> Error in function COMMON-LISP::%%TYPEP:  Unknown type specifier: (PATHNAME)
> in cmucl, and similar errors in sbcl and clisp.

You probably want this:
(typecase #P"/tmp" (pathname :true) (otherwise :false))

TYPECASE is supposed to accept only one type specifier per clause. Thus, 
while (STRING) is a valid type specifier, (PATHNAME) is not. You could 
type (OR PATHNAME), though.

Juanjo
From: Pascal Bourguignon
Subject: Re: typecase PATHNAME ?
Date: 
Message-ID: <873c17246y.fsf@thalassa.informatimago.com>
Juan Jose Garcia Ripoll <·········@yahoo.de> writes:

> Pascal Bourguignon wrote:
> > * (typecase #P"/tmp/" ((string) :true) (otherwise :false))
> > :FALSE
> > * (typecase #P"/tmp/" ((pathname) :true) (otherwise :false))
> > Error in function COMMON-LISP::%%TYPEP:  Unknown type specifier: (PATHNAME)
> > in cmucl, and similar errors in sbcl and clisp.
> 
> You probably want this:
> (typecase #P"/tmp" (pathname :true) (otherwise :false))
> 
> TYPECASE is supposed to accept only one type specifier per
> clause. Thus, while (STRING) is a valid type specifier, (PATHNAME) is
> not. You could type (OR PATHNAME), though.

Ok. Thank you.

/me will have to check all my typecases...
-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.