Anyone know a efficient way of eliminating runtime checks on iterators?
Mine seem first to need a type dispatch (or method specialisation), then
various conditions to be called each time. Beyond compiling the function
with the variables instated at runtime I can't see a way around this.
--------------
John Thingstad
On Apr 8, 6:22 am, "John Thingstad" <·······@online.no> wrote:
> Anyone know a efficient way of eliminating runtime checks on iterators?
> Mine seem first to need a type dispatch (or method specialisation), then
> various conditions to be called each time. Beyond compiling the function
> with the variables instated at runtime I can't see a way around this.
I'm not sure I understand your question, but have you tried using
closures as iterators? My impression (which anyone who really cares
should verify on their own; I'm not certain) is that this approach is
faster than using an instance, in most implementations anyway.
So, for example:
(defmethod iterator ((list list))
(lambda (op)
(ecase op
(:get (pop list))
(:more? list))))
This way you get rid of the type dispatch on each iteration.
Does that help?
-- Scott
P� Tue, 08 Apr 2008 18:03:17 +0200, skrev Scott Burson
<········@gmail.com>:
> On Apr 8, 6:22 am, "John Thingstad" <·······@online.no> wrote:
>> Anyone know a efficient way of eliminating runtime checks on iterators?
>> Mine seem first to need a type dispatch (or method specialisation), then
>> various conditions to be called each time. Beyond compiling the function
>> with the variables instated at runtime I can't see a way around this.
>
> I'm not sure I understand your question, but have you tried using
> closures as iterators? My impression (which anyone who really cares
> should verify on their own; I'm not certain) is that this approach is
> faster than using an instance, in most implementations anyway.
>
> So, for example:
>
> (defmethod iterator ((list list))
> (lambda (op)
> (ecase op
> (:get (pop list))
> (:more? list))))
>
> This way you get rid of the type dispatch on each iteration.
>
> Does that help?
>
> -- Scott
Yes, something like that.
--------------
John Thingstad
John Thingstad wrote:
> Anyone know a efficient way of eliminating runtime checks on iterators?
> Mine seem first to need a type dispatch (or method specialisation), then
> various conditions to be called each time. Beyond compiling the function
> with the variables instated at runtime I can't see a way around this.
>
> --------------
> John Thingstad
Ron's take on iterators
http://rondam.blogspot.com/2008/02/joy-of-iterators.html
On Apr 8, 6:05 pm, vanekl <·····@acd.net> wrote:
> John Thingstad wrote:
> > Anyone know a efficient way of eliminating runtime checks on iterators?
> > Mine seem first to need a type dispatch (or method specialisation), then
> > various conditions to be called each time. Beyond compiling the function
> > with the variables instated at runtime I can't see a way around this.
>
> > --------------
> > John Thingstad
>
> Ron's take on iteratorshttp://rondam.blogspot.com/2008/02/joy-of-iterators.html
http://common-lisp.net/project/cl-enumeration/ (shameless plug)
--
Marco
P� Tue, 08 Apr 2008 15:22:26 +0200, skrev John Thingstad
<·······@online.no>:
> Anyone know a efficient way of eliminating runtime checks on iterators?
> Mine seem first to need a type dispatch (or method specialisation), then
> various conditions to be called each time. Beyond compiling the function
> with the variables instated at runtime I can't see a way around this.
>
Thanks all.
But I think I have found what I am looking for in Edi Weitz closure
composition in CL-PPCRE.
--------------
John Thingstad