2015-06-23 07:20:40 |
CHIBA Masaomi |
description |
* What I do and what happens:
(setf (find-class 'my-string-class)
(find-class 'cl:string))
(make-sequence 'my-string-class 3 :initial-element #\.)
;error :string is too hairy for sequence functions.
(concatenate 'my-string-class "foo" "bar")
;error :string is too hairy for sequence functions.
(concatenate '(my-string-class 6) "foo" "bar")
;error :string is too hairy for sequence functions.
* What I expected to happen:
(concatenate 'my-string-class "foo" "bar")
;=> "foobar"
(concatenate '(my-string-class 6) "foo" "bar")
;=> "foobar"
* See also:
(deftype my-string-type (&rest args)
`(cl:string ,@args))
(make-sequence 'my-string-type 3 :initial-element #\.)
;=> "..."
(concatenate 'my-string-type "foo" "bar")
;=> "foobar"
(concatenate '(my-string-type 6) "foo" "bar")
;=> "foobar"
* Analysis:
CL:MAKE-SEQUENCE adjusted-type'ed type-specifier with SB-EXT:TYPEXPAND, but it should be expanded recursively with SB-EXT::TYPEXPAND-ALL etc.
((eq expanded-type 'string) '(vector character))
==>
((eq (typexpand-all expanded-type) 'string) '(vector character))
etc.
Environment:
SBCL 1.2.12
uname -a:
Linux t 4.1.0-rc6-t #1 SMP PREEMPT Wed Jun 3 06:48:43 JST 2015 x86_64 GNU/Linux
*features*:
(:sbcl-uses-sb-rotate-byte :generic-sequences :cl-unicode :newline-is-linefeed
:has-vt :has-bell :has-escape :has-linefeed :has-return :has-backspace
:has-tab :has-page :has-rubout :declare-types :esrap.can-handle-left-recursion
:esrap.multiple-transforms :esrap.function-terminals
:esrap.expression-start-terminals mopp::have-mop :cl-json-clos :cl-json
:arc-compat :asdf-system-connections :5am :kmr-mop :rune-is-character
:named-readtables :hunchentoot :sbcl-debug-print-variable-alist :cl-fad
:bordeaux-threads cffi-features:flat-namespace cffi-features:x86-64
cffi-features:unix :cffi cffi-sys::flat-namespace :cl-ppcre :flexi-streams
:chunga :split-sequence :closer-mop :thread-support chipz-system:gray-streams
:swank :quicklisp :sb-bsd-sockets-addrinfo :asdf-package-system :asdf3.1
:asdf3 :asdf2 :asdf :os-unix :non-base-chars-exist-p :asdf-unicode
:alien-callbacks :ansi-cl :ash-right-vops :c-stack-is-control-stack
:common-lisp :compare-and-swap-vops :complex-float-vops :cycle-counter :elf
:float-eql-vops :gencgc :ieee-floating-point :inline-constants
:integer-eql-vop :interleaved-raw-slots :largefile :linkage-table :linux
:little-endian :memory-barrier-vops :multiply-high-vops :os-provides-blksize-t
:os-provides-dladdr :os-provides-dlopen :os-provides-getprotoby-r
:os-provides-poll :os-provides-putwc :os-provides-suseconds-t
:package-local-nicknames :precise-arg-count-error :raw-instance-init-vops
:sb-after-xc-core :sb-core-compression :sb-doc :sb-eval :sb-futex :sb-ldb
:sb-package-locks :sb-simd-pack :sb-source-locations :sb-test :sb-thread
:sb-unicode :sb-xref-for-internals :sbcl :stack-allocatable-closures
:stack-allocatable-fixed-objects :stack-allocatable-lists
:stack-allocatable-vectors :stack-grows-downward-not-upward :symbol-info-vops
:unix :unwind-to-frame-and-call-vop :x86-64) |
* What I do and what happens:
(deftype my-string-type (&rest args)
`(cl:string ,@args))
(concatenate 'my-string-type "foo" "bar")
;=> "foobar"
(concatenate '(my-string-type 6) "foo" "bar")
;=> "foobar"
(setf (find-class 'my-string-type)
(find-class 'cl:string))
; warning: redefining DEFTYPE type to be a class: cl-user::my-string-type
(make-sequence 'my-string-type 3 :initial-element #\.)
;error :string is too hairy for sequence functions.
(concatenate 'my-string-type "foo" "bar")
;error :string is too hairy for sequence functions.
(concatenate '(my-string-type 6) "foo" "bar")
;error :string is too hairy for sequence functions.
* What I expected to happen:
;; after (setf (find-class 'my-string-type) ..)
(concatenate 'my-string-class "foo" "bar")
;=> "foobar"
(concatenate '(my-string-class 6) "foo" "bar")
;=> "foobar"
* Analysis:
CL:MAKE-SEQUENCE adjusted-type'ed type-specifier with SB-EXT:TYPEXPAND, but it should be expanded recursively with SB-EXT::TYPEXPAND-ALL etc.
((eq expanded-type 'string) '(vector character))
==>
((eq (typexpand-all expanded-type) 'string) '(vector character))
etc.
Environment:
SBCL 1.2.12
uname -a:
Linux t 4.1.0-rc6-t #1 SMP PREEMPT Wed Jun 3 06:48:43 JST 2015 x86_64 GNU/Linux
*features*:
(:sbcl-uses-sb-rotate-byte :generic-sequences :cl-unicode :newline-is-linefeed
:has-vt :has-bell :has-escape :has-linefeed :has-return :has-backspace
:has-tab :has-page :has-rubout :declare-types :esrap.can-handle-left-recursion
:esrap.multiple-transforms :esrap.function-terminals
:esrap.expression-start-terminals mopp::have-mop :cl-json-clos :cl-json
:arc-compat :asdf-system-connections :5am :kmr-mop :rune-is-character
:named-readtables :hunchentoot :sbcl-debug-print-variable-alist :cl-fad
:bordeaux-threads cffi-features:flat-namespace cffi-features:x86-64
cffi-features:unix :cffi cffi-sys::flat-namespace :cl-ppcre :flexi-streams
:chunga :split-sequence :closer-mop :thread-support chipz-system:gray-streams
:swank :quicklisp :sb-bsd-sockets-addrinfo :asdf-package-system :asdf3.1
:asdf3 :asdf2 :asdf :os-unix :non-base-chars-exist-p :asdf-unicode
:alien-callbacks :ansi-cl :ash-right-vops :c-stack-is-control-stack
:common-lisp :compare-and-swap-vops :complex-float-vops :cycle-counter :elf
:float-eql-vops :gencgc :ieee-floating-point :inline-constants
:integer-eql-vop :interleaved-raw-slots :largefile :linkage-table :linux
:little-endian :memory-barrier-vops :multiply-high-vops :os-provides-blksize-t
:os-provides-dladdr :os-provides-dlopen :os-provides-getprotoby-r
:os-provides-poll :os-provides-putwc :os-provides-suseconds-t
:package-local-nicknames :precise-arg-count-error :raw-instance-init-vops
:sb-after-xc-core :sb-core-compression :sb-doc :sb-eval :sb-futex :sb-ldb
:sb-package-locks :sb-simd-pack :sb-source-locations :sb-test :sb-thread
:sb-unicode :sb-xref-for-internals :sbcl :stack-allocatable-closures
:stack-allocatable-fixed-objects :stack-allocatable-lists
:stack-allocatable-vectors :stack-grows-downward-not-upward :symbol-info-vops
:unix :unwind-to-frame-and-call-vop :x86-64) |
|