On 02.01.2010, at 18:16, Rich Hickey wrote:
> That's documented:
>
> ;from (doc deftype)
>
> "In the method bodies, the (unqualified) name can be used to name the
> class (for calls to new, instance? etc)."
Thanks, that solves the problem perfectly well!
Konrad.
--
You received this message b
On Sat, Jan 2, 2010 at 6:23 AM, Konrad Hinsen
wrote:
> On 01.01.2010, at 23:56, Hugo Duncan wrote:
>
>>> I want to create a new instance of a deftype from inside one of its
>>> methods.
>>
>> I ended-up using extend-type for this case.
>
> That's probably the cleanest solution, but you lose the pe
Hi,
Am 02.01.2010 um 12:23 schrieb Konrad Hinsen:
> (deftype Bar
> [i]
> Foo
> (foo [] (new Bar (inc i
>
> Its drawback is relying on an undocumented feature: the value of Foo
> inside the methods is the class Foo being defined.
Isn't this only the case for AOT compiled deftype? F
Sorry, I think my reply got lost...
Inside deftype methods the symbol "Bar" is the name of the class. You
can use the constructor (Bar. (inc i)) instead. Again, note the "."
after Bar.
On Sat, Jan 2, 2010 at 1:23 PM, Konrad Hinsen
wrote:
> On 01.01.2010, at 23:56, Hugo Duncan wrote:
>
>>> I want
(note the .)
(deftype Bar
[i]
Foo
(foo [] (Bar. (inc i
/Jonas
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patien
On 01.01.2010, at 23:56, Hugo Duncan wrote:
>> I want to create a new instance of a deftype from inside one of its
>> methods.
>
> I ended-up using extend-type for this case.
That's probably the cleanest solution, but you lose the performance
benefit of defining methods right in the type defini
On Fri, 01 Jan 2010 17:13:01 -0500, Konrad Hinsen
wrote:
> I want to create a new instance of a deftype from inside one of its
> methods.
I ended-up using extend-type for this case.
Hugo
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post t
I want to create a new instance of a deftype from inside one of its
methods. A basic example would be
(defprotocol Foo
(foo [x]))
(deftype Bar
[i]
Foo
(foo [] (Bar (inc i
(foo (Bar 0))
This fails with an exception:
java.lang.ClassCastException: java.lang.Class cannot be cast