Re: The pipe's sharp end

2005-05-07 Thread Brad Bowman

> What if you give it a 1-ary sub that you thought was slurpy, and in
> fact does something different (hmm, that doesn't seem very likely). 
> How do we handle options and the like?

.assuming ?  Although map would be simpler, clearer and more flexible.

> Still, semantics like that are dwimmery, and the pipe operators are as
> yet non dwimmy, so we'd be paying a price.  Is that more or less than
> three characters (when the pipe operators are already three
> characters)?
> 
> Also, as you point out below, the semantics are less than obvious for
> subs with arity > 1.  So it would be tough to figure out what IM
> anyway.

I was hoping it was just confusing to me and that the best
interpretation would be clear to other on the list.

It's not so I'm happy to ditch the idea.

Brad

-- 
People with intelligence will use it to fashion both true and false and will
try to push through whatever they want with their clever reasoning.  This is
injury from intelligence.
  Nothing you do will have effect if you do not use truth. -- Hagakure



Re: The pipe's sharp end

2005-05-06 Thread Luke Palmer
On 5/6/05, Brad Bowman <[EMAIL PROTECTED]> wrote:
> Hi,
> 
>   <$*IN> ==> process() ==> print;
> 
> This A06 example got me thinking.
> Could non-variadic subrountines in a pipeline be useful?
> 
> A single arg sub or block could be a map without the "map":
> 
>   <$*IN> ==> &process ==> print;
>   # print map { process($_) } <$*IN>
> 
>   (1..6) ==> { $_++ } ==> say;

Hmm.  Well, considering that that is the same as:

(1..6) ==> map { $_++ } ==> say;

And in fact, you can just slap map in front of anything you want to do
that, I don't think we're buying much by letting you leave it off. 
What if you give it a 1-ary sub that you thought was slurpy, and in
fact does something different (hmm, that doesn't seem very likely). 
How do we handle options and the like?

Still, semantics like that are dwimmery, and the pipe operators are as
yet non dwimmy, so we'd be paying a price.  Is that more or less than
three characters (when the pipe operators are already three
characters)?

Also, as you point out below, the semantics are less than obvious for
subs with arity > 1.  So it would be tough to figure out what IM
anyway.

Luke


The pipe's sharp end

2005-05-06 Thread Brad Bowman
Hi,

  <$*IN> ==> process() ==> print;

This A06 example got me thinking.
Could non-variadic subrountines in a pipeline be useful?

A single arg sub or block could be a map without the "map":

  <$*IN> ==> &process ==> print; 
  # print map { process($_) } <$*IN>

  (1..6) ==> { $_++ } ==> say;

A two param sub might reduce (I just caught up on the thread)
but that wouldn't play nicely with infinite or lazy lists.
Since that seems to be the point of pipelines, it's probably
a bad idea.  It could produce a stream of the accumulated results:

  (1..6) ==> { $^a + $^b } ==> ...;
  # (3,6,10,15,21) or (1,3,6,10,15,21)

Alternatively, the list could be processed pairwise, 
with or without overlaps, producing:

  (1+2),(2+3),(3+4),(4+5),(5+6)  # overlapping
  (1+2),  (3+4),  (5+6)  # non-overlapping

Overlapping seems more useful and less likely to cause
problems with an odd length list.

I think I should just post this before I start on:
  (1..6) ==> { $^a ... $^b ... $^c }


Brad

-- 
 It is bad to carry even a good thing too far.  Even concerning things such as
 Buddhism,  Buddhist sermons, and moral lessons, talking too much will bring
 harm.  -- Hagakure http://bereft.net/hagakure/