Re: Types in Lisp?
I suggest checking the second value as well (valid-p).
From: <owner-lisp-hug@lispworks.com> on behalf of Raymond Wiker <rwiker@gmail.com>
Reply-To: Raymond Wiker <rwiker@gmail.com>
Date: Monday, February 13, 2017 at 8:19 AM
To: David McClain <dbm@refined-audiometrics.com>
Cc: "lisp-hug@lispworks.com Lispworks [lisp-hug@lispworks.com]" <lisp-hug@lispworks.com>
Subject: EXT: Re: Types in Lisp?
I assume you mean LW:SIMPLE-CHAR?
I'd test for type equivalence with subtype, like so:
(and (subtypep 'lw:simple-char 'cl:character)
(subtypep 'cl:character 'lw:simple-char))
On Mon, Feb 13, 2017 at 1:57 PM, David McClain <dbm@refined-audiometrics.com<mailto:dbm@refined-audiometrics.com>> wrote:
I haven’t thought much about Types for quite some time. I have been enjoying my Lisp sessions, and breathe the freedom of expression that one can feel after an extended round of ML or OCaml programming.
But lately, this group has seen some messages regarding the type of characters in strings, and that got me looking at some of my code, and delving into the world of Unicode and the Lisp Babel library. I managed to avoid this until now. But Apple permits Unicode file names and that has been giving me some heartburn.
In pouring through the LW docs, I came across the statement that CL:SIMPLE-CHAR is now the same as CL:CHARACTER, and has been “deprecated”. Presumably that means that we can still use code that refers to CL:SIMPLE-CHAR, but be aware that this named type may disappear at some time in the future. That seems to be the case for now, because Babel 0.5.0 uses that identifier and it appears to run just fine.
So that got me to wondering, how can I test for type equivalence in Lisp? How can I verify that CL:SIMPLE-CHAR is the same type as CL:CHARACTER? I do accept their word for it, but in general, how can I decide that one type ‘A is equivalent to another type ‘B in my Lisp code? Is that even possible in Lisp?
- DM
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com<mailto:lisp-hug@lispworks.com>
http://www.lispworks.com/support/lisp-hug.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lispworks.com_support_lisp-2Dhug.html&d=DQMFaQ&c=IV_clAzoPDE253xZdHuilRgztyh_RiV3wUrLrDQYWSI&r=yTegpHW1zevhgxHhUFFvwA&m=As8xQXxpzHvPLQlSndsznKyAPzYZWzNyhEQbawpLZrA&s=MyDNBiGG4HBI8gJpNg6fpdtgw5tPPahbAqmOKvcUaM4&e=>
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html