Gaal Yahas writes:

> On Tue, May 09, 2006 at 11:23:48AM +0100, Smylers wrote:
> 
> > So I have the list generated by the scan.  And?  What do I do with
> > it?  I can't think of any situation in my life where I've been
> > wanting such a list.
> 
> Scans are useful when the intermediate results are interesting, as
> well as when you want to cut off a stream once some threshold
> condition is met.

OK, we're getting closer, but that still sounds quite abstract to me.

>     item [+] 1 .. 10;           # 10th triangular number
>     list [+] 1 .. 10;           # 10 first triangular number
>     first { $_ > 42 } [+] 1 ..*  # first triangular number over 42

Same question, but one level further on: why would I want the first 10
triangular numbers, or the first triangular number over 42?

Sorry to keep going on like this, but I'm still struggling to see what
this gets us.  Is wanting to do something like that sufficiently common
in real-life situations?

I've seen other people ask similar questions about features such as
juctions and hyperoperators (and folk were able to come up with suitable
examples), but in those cases there was also response that these are
features which beginners can choose to ignore.

I'd have no particular objection to scans being in Perl 6 if those of us
without sufficient imagination were able to just ignore them, and act
like they don't exist.  But if things that look like reductions
sometimes turn out to be scans then I have to know about them (even if
just to avoid them) anyway.

And I have no problem in thinking of lots of situations where I'd find
reductions handy.  It slightly unnerves me that I suspect some of those
would happen to be in list context -- not because I wanted a list, but
because things like C<map> blocks and C<say> arguments are always lists.

Are scans sufficiently useful that they are worth making reductions more
awkward, and have a higher barrier to entry (since you now have to learn
about both reductions and scans at the same time in order to be able to
use only one of them).

> If you have a series whose sum yields closer and closer approximations
> of some value, you can use a scan to efficiently cut off once some
> epsilon is reached.

OK, I can see why mathematicians and engineers would want to do that.
But that's a specialist field; couldn't this functionality be provided
in a module?  I'm unconvinced that core Perl needs features for closely
approximating mathematicians any more than it needs, say, CGI parameter
parsing or DBI -- they're all niches that some people use lots and
others won't touch at all.

Smylers

Reply via email to