factor/basis/specialized-vectors/functor/functor.factor

39 lines
747 B
Factor
Raw Normal View History

! Copyright (C) 2008, 2009 Slava Pestov.
2008-11-14 21:18:16 -05:00
! See http://factorcode.org/license.txt for BSD license.
2009-07-07 17:27:14 -04:00
USING: accessors alien.c-types functors sequences sequences.private growable
2008-12-08 15:58:00 -05:00
prettyprint.custom kernel words classes math parser ;
QUALIFIED: vectors.functor
2008-11-14 21:18:16 -05:00
IN: specialized-vectors.functor
FUNCTOR: define-vector ( T -- )
V DEFINES-CLASS ${T}-vector
2008-11-14 21:18:16 -05:00
A IS ${T}-array
S IS ${T}-sequence
2008-12-03 01:05:32 -05:00
<A> IS <${A}>
2008-11-14 21:18:16 -05:00
>V DEFERS >${V}
2008-11-14 21:18:16 -05:00
V{ DEFINES ${V}{
WHERE
V A <A> vectors.functor:define-vector
2008-11-14 21:18:16 -05:00
M: V contract 2drop ;
2009-07-07 17:27:14 -04:00
M: V byte-length underlying>> byte-length ;
M: V pprint-delims drop \ V{ \ } ;
2008-11-14 21:18:16 -05:00
M: V >pprint-sequence ;
M: V pprint* pprint-object ;
SYNTAX: V{ \ } [ >V ] parse-literal ;
2008-11-14 21:18:16 -05:00
INSTANCE: V growable
INSTANCE: V S
2008-11-14 21:18:16 -05:00
;FUNCTOR