On Thu, Feb 26, 2009 at 2:19 PM, Pal-Kristian Engstad
<[email protected]> wrote:
> Jonathan S. Shapiro wrote:
>> Yes, and instantaneously. Result of years of practice, and does not
>> invalidate your point in the slightest.
>>
> ;-)
>> notion of range is easily generalized to the notion of set. The
>> problem with this approach is that it does not handle irregular loops
>> well (e.g. all *even* slots in a vector), and it has a hard time
>> dealing with co-induction.
>>
> Agreed, though most cases like these would benefit to go to a more
> general loop system. Comprehensions can also help:
>
> { i <- 0..n-1 when i mod 2 == 0 } |> ...
I think the python notion iterable combined with a range() method is
easier on the eyes. In python, evens is just range(0,n,2). It also
requires simpler compiler optimizations, since the high level control
flow isn't higher order.
Unfortunately, I doubt the python notion of an iterable is expressible
in bitc type classes, since it definitely isn't in Haskell. It'd be
something like
class Iterable Container a =
iter :: Container a -> b
next :: b -> a * b
where the type b depends on Container and a. Given that you keep
saying that full overloading of + requires a cubic number of
expressions, rather that the quadratic number that would be required
in a perfect world, this notion of iterable is probably out of reach.
:)
Geoffrey
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev