> Alexis, think of a lazy sequence as something that the rest of the program 
> will explore. In addition to a GUI-based exploration, I would love to see a 
> programmatic one. Imagine 
> 
>  (explore-lazy lazy-sequence:exp strictness-pattern:exp)
> 
> where (the value of) strictness-pattern is a function that pokes around 
> lazy-sequence and displays. You could provide default strictness-pattern 
> values and you could even provide strictness-patterns that dump values into a 
> scrollable snip. But others could program their own strictness-patterns. The 
> key would be to keep it simple. 

I've thought about this some more since you sent me this message, and I've come 
up with a few potentially interesting ideas for inspecting sequence types. I 
may try and implement some of them to play with that idea.

To put it simply, I think it would be helpful to allow sequences to expose some 
information about themselves through optional method implementations that would 
be displayed and organized via inspection methods. I've already tried something 
like that in the form of `known-finite?` from gen:countable, and it would 
certainly be possible to include some additional methods for extracting 
sequence metadata. It might even be possible to use some of that metadata to 
produce a sequence-custom-write structure type property for default printing of 
sequence, similar to the property already exposed for contracts.

> Note that contracts for lazy sequences could also check via 
> strictness-patterns and memoize the exploration path. If the rest of the 
> program re-explores it's cached in the proxy and if it goes beyond that 
> exploration, consider it a contract violation.

I will note here that Racket streams automatically perform memoization, so once 
a stream has been evaluated, its elements are automatically cached. This itself 
has its tradeoffs (forcing the same sequence twice for the side-effects won't 
work), but it's probably what would be desired in the large majority of cases.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to