! Should actually be 0 23 2^ 1 - [a,b]
[ string-nth ] final-info first interval>> 0 23 2^ [a,b] =
] unit-test
+
+! Optimization on instance?
+[ f ] [ [ { number } declare fixnum instance? ] { tag fixnum? } inlined? ] unit-test
+
+UNION: ?fixnum fixnum POSTPONE: f ;
+[ t ] [ [ { ?fixnum } declare fixnum instance? ] { tag fixnum? } inlined? ] unit-test
+[ t ] [ [ { fixnum } declare fixnum instance? ] { tag fixnum? } inlined? ] unit-test
+
+! Actually check to make sure that the generated code works properly
+: instance-test-1 ( x -- ? ) { ?fixnum } declare fixnum instance? ;
+: instance-test-2 ( x -- ? ) { number } declare fixnum instance? ;
+: instance-test-3 ( x -- ? ) { POSTPONE: f } declare \ f instance? ;
+
+[ t ] [ 1 instance-test-1 ] unit-test
+[ f ] [ f instance-test-1 ] unit-test
+[ t ] [ 1 instance-test-2 ] unit-test
+[ f ] [ 1.1 instance-test-2 ] unit-test
+[ t ] [ f instance-test-3 ] unit-test
} case
] "custom-inlining" set-word-prop
+:: inline-instance ( node -- quot/f )
+ node in-d>> first2 [ value-info ] bi@ literal>> :> ( obj klass )
+ klass class? [
+ {
+ [ klass \ f = not ]
+ [ obj class>> \ f class-not class-and klass class<= ]
+ } 0&&
+ [ [ drop >boolean ] ]
+ [ klass "predicate" word-prop '[ drop @ ] ] if
+ ] [ f ] if ;
+
+\ instance? [ inline-instance ] "custom-inlining" set-word-prop
+
ERROR: bad-partial-eval quot word ;
: check-effect ( quot word -- )
\ new [ inline-new ] 1 define-partial-eval
-\ instance? [
- dup class?
- [ "predicate" word-prop ] [ drop f ] if
-] 1 define-partial-eval
-
! Shuffling
: nths-quot ( indices -- quot )
[ [ '[ _ swap nth ] ] map ] [ length ] bi