Clojure 1.1.0-alpha-SNAPSHOT
user=> (defprotocol P (foo [x]))
P
user=> (deftype T [f] [P] (foo [x] x))
java.lang.ClassCastException: clojure.lang.Var cannot be cast to
java.lang.Class (NO_SOURCE_FILE:2)
?! thanks for any help.
(deftype A
[#^somePrimitive someField])
(deftype B
[#^A Avalue])
This brings up an error:
Unknown location:
error: java.lang.ClassNotFoundException: A
So how would I define a type that includes another type?
> So how would I define a type that includes another type?
my guess: type hints take java types, and you are giving a clojure
type. the docs for deftype say you can get a java type for the deftype
if you compile. ?
When AOT compiling, generates compiled bytecode for a class with the
given name (a symbol), prepends the current ns as the package, and
writes the .class file to the *compile-path* directory. When
dynamically evaluated, the class will have a generated name.
Am 30.12.2009 um 00:19 schrieb Rob Lachlan:
> (deftype B
> [#^A Avalue])
>
> So how would I define a type that includes another type?
Did you try: (deftype B [#^::A Avalue])?
I don't know whether this works, but it's the obvious idea.
Sincerely
Meikel
http://stackoverflow.com/questions/1976423/nested-types-in-clojure
:-)
user=> (defprotocol P (foo [x]))
P
user=> (deftype A [] [P] (.foo [x]))
java.lang.RuntimeException: java.lang.ClassCastException:
clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol
(NO_SOURCE_FILE:0)
On Tue, Dec 29, 2009 at 12:08 PM, Raoul Duke <rao...@gmail.com> wrote: