Lisp HUG Maillist Archive

Types in Lisp?

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
http://www.lispworks.com/support/lisp-hug.html

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> 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
http://www.lispworks.com/support/lisp-hug.html

Re: Types in Lisp?

Ach! Of course… thanks for that.

What I have run into, isn’t really a LW problem with character encodings after all… LW seems to handle extended characters in filenames just fine. I spent the entire morning throwing test case at LW and Babel. Not sure what Babel is actually producing, but it differs from LW’s char-code encodings. But that doesn’t really matter for my uses.

The problem arises that when I want to have a shell execute some command using SYS:CALL-SYSTEM, like Apple’s afconvert utility, the shell balks at the extended chars and cannot find the file. You’d think, that if a company were going to allow Unicode filenames, then they’d make their utilities capable of handling such. But no…

- DM


On Feb 13, 2017, at 06:19, Raymond Wiker <rwiker@gmail.com> wrote:

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> 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
http://www.lispworks.com/support/lisp-hug.html


Re: Types in Lisp?

Hi David,

I believe afconvert supports Unicode filenames. I just tried in the Terminal with no problem.
Now this could be different from making a system call (like exec), but again I believe this should be ok.


Best,
Cam


On Feb 13, 2017, at 16:27, David McClain <dbm@refined-audiometrics.com> wrote:

Ach! Of course… thanks for that.

What I have run into, isn’t really a LW problem with character encodings after all… LW seems to handle extended characters in filenames just fine. I spent the entire morning throwing test case at LW and Babel. Not sure what Babel is actually producing, but it differs from LW’s char-code encodings. But that doesn’t really matter for my uses.

The problem arises that when I want to have a shell execute some command using SYS:CALL-SYSTEM, like Apple’s afconvert utility, the shell balks at the extended chars and cannot find the file. You’d think, that if a company were going to allow Unicode filenames, then they’d make their utilities capable of handling such. But no…

- DM


On Feb 13, 2017, at 06:19, Raymond Wiker <rwiker@gmail.com> wrote:

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> 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
http://www.lispworks.com/support/lisp-hug.html



Re: Types in Lisp?

Hi Camille,

Yes, I also found that running from an Apple Terminal makes it run just fine. It appears that LW is not performing the correct character translation from within its own Shell nor from SYS:CALL-SYSTEM. I will try Martin’s suggestion of writing a UTF-8 script file and using that from a CALL-SYSTEM.

- DM

On Feb 14, 2017, at 00:47, Camille Troillard <camille.troillard@icloud.com> wrote:

Hi David,

I believe afconvert supports Unicode filenames. I just tried in the Terminal with no problem.
Now this could be different from making a system call (like exec), but again I believe this should be ok.


Best,
Cam


On Feb 13, 2017, at 16:27, David McClain <dbm@refined-audiometrics.com> wrote:

Ach! Of course… thanks for that.

What I have run into, isn’t really a LW problem with character encodings after all… LW seems to handle extended characters in filenames just fine. I spent the entire morning throwing test case at LW and Babel. Not sure what Babel is actually producing, but it differs from LW’s char-code encodings. But that doesn’t really matter for my uses.

The problem arises that when I want to have a shell execute some command using SYS:CALL-SYSTEM, like Apple’s afconvert utility, the shell balks at the extended chars and cannot find the file. You’d think, that if a company were going to allow Unicode filenames, then they’d make their utilities capable of handling such. But no…

- DM


On Feb 13, 2017, at 06:19, Raymond Wiker <rwiker@gmail.com> wrote:

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> 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
http://www.lispworks.com/support/lisp-hug.html




Updated at: 2020-12-10 08:31 UTC