Re: remote generators and a macro language proposal

2002-10-10 Thread Larry Wall

On Thu, 10 Oct 2002, Chip Salzenberg wrote:
: According to Luke Palmer:
:  for ( grep { $_{smoker} and $_{age}  18 } Subscribers ) {
:  .send($Cigarette_Advertisement)
:  }
: 
: Hm, would this work too:
: 
:   for ( grep { .{smoker} and .{age}  18 } Subscribers )
: { .send($ciggie_ad) }
: 
: ?  I think  .{x}  reads better than  $_{x} , esp. in parallel with the
: method call in the same loop.

Didn't see the original, but if those are attributes, why wouldn't
it just be:

for grep { .smoker and .age  18 } Subscribers {
.send($ciggie_ad)
}

'Course, this might be more readable:

for Subscribers {
.send($ciggie_ad) if .smoker and .age  18;
}

Most smokers don't know what grep means, after all...

Larry




RE: remote generators

2002-07-22 Thread [EMAIL PROTECTED]

From: david nicol [EMAIL PROTECTED]
 foreach (grep { $_-{smoker} and $_-{age}  18 } @Subscribers){ 
 $-send($Cigarette_Advertisement) 
   } 
 
 This would imply an extension of the array tieing 
 interface, so we can send the grep block to the
 data server, and get back a generator object for
 foreach to shift qualifying subscribers off of.

I'm uncomfortable with the idea of an object reaching out and overriding
other functions.  What if I really want to grep through everything in the
array? How would this work if the grep block is passed to another server:

  grep {
  print STDERR 'testing:', $_{name}, \n;
  $_{smoker} and $_{age}  18;
  }

That's not to say that grep and map methods might not be a nifty idea as
tied array methods, but let's keep it to an object-perpsective, say
something like this:

  @Subscribers-grep({ $_-{smoker} and $_-{age}  18 });

I'll grant you that tied hashes already reach out and override commands
like each and keys, but those are very simple commands that only take a
hash as an argument, not other complicated arguments like blocks.

Personally, I can't help but think that in any situation in you need to use
a tied array for that sort of complexity you'd probably do better with a
real SOAP object that has methods like return_qualified_smokers.

-Miko


mail2web - Check your email from the web at
http://mail2web.com/ .