On 10/24/2010 07:07 PM, Ben Goldberg wrote:
> I know that perl6 has / will have lazy strings, since (in
> S32::Containers) the List role defines a cat method, which returns a
> Cat object, which "does the Str interface, but generates the string
> lazily."
> 
> First, are Cat objects documented anywhere else?

I don't think so. It's one of the areas that will become clearer when
somebody actually implements them.

> Secondly, if a regular expression match is done on a lazy string, is
> that lazy string turned into a normal string?

No; that wouldn't make much sense. It would be like reifing lazy lists
prior to iteration.

> If we can efficiently match against a lazy string, and if this doesn't
> turn the lazy string into a (large) normal string, then the best way
> to process a file might be something similar to:
>    my $fh = open ... err die;
>    my $contents = cat($fh.lines);
> , followed by matching on $contents.
> 
> Better still would be to provide a way for filehandles to be directly
> asked to produce a lazy Str which reflects the file.

I guess there's no good reason not to have a .Cat method in the IO class
- another thing that'll likely appear when Cats are implemented.

Cheers,
Moritz

Reply via email to