Re: lazy context

2005-05-20 Thread C. Scott Ananian
On Fri, 20 May 2005, Yuval Kogman wrote:
then it is not finalized into a real value. Here's how the range
operator would be implemented:
sub infix:.. ($from, $to where { $to  $from }){ reverse $to .. 
$from }
sub infix:.. ($from, $to) { lazy gather {
while ($from = $to) {
take($from++);
}
}}
This is very elegant.  It might be worthwhile for someone to attempt to 
define a 'core perl' set of operators, etc, so that the 'rest of perl' can 
be defined in perl proper...
 --scott

Pakistan FBI assassination Israel AVBUSY BATF ODEARL [Hello to all my fans in domestic surveillance] 
interception domestic disruption KMFLUSH ODENVY IDEA DES MI5 arrangements
 ( http://cscott.net/ )


Re: reduce metaoperator on an empty list

2005-05-19 Thread C. Scott Ananian
On Wed, 18 May 2005, Rob Kinyon wrote:
On 5/18/05, Stuart Cook [EMAIL PROTECTED] wrote:
To summarise what I think everyone is saying, []-reducing an empty
list yields either:
1) undef (which may or may not contain an exception), or
2) some unit/identity value that is a trait of the operator,
depending on whether or not people think (2) is actually a good idea.
I would think that the Principle of Least Surprise points to (1),
given that the standard explanation of the [EMAIL PROTECTED] is eval join( '+', 
@x
) ...
I'd say the principle of least surprise points to (1); in the sense that 
$sum = [+] @x; would Just Work, etc.

I also have a vague sense that the 'identity' value for an operator might 
also be useful in other places in the compiler (enabling optimizations, 
etc).  Providing it as a trait means that these 'other things' could work 
even with user-defined operators.  (And leaving the trait undefined gives 
you the behavior (1), if that's what you want.)
 --scott

Albanian LICOZY shotgun CABOUNCE plastique Sigint Justice fissionable 
LITEMPO KGB KUCAGE LIONIZER ESCOBILLA North Korea CLOWER genetic NRA
 ( http://cscott.net/ )


Re: How do I... invoke a method reference

2005-05-19 Thread C. Scott Ananian
On Thu, 19 May 2005, Juerd wrote:
Ingo Blechschmidt skribis 2005-05-19 22:45 (+0200):
  class Foo {
method bar() { 42 }
method baz() { bar }
  }
  my $ref = Foo.baz;
My guess:
   Foo.$ref
   $object.$ref
Just like in Perl 5.
I think Ingo was trying to explicitly specify the normally-implicit 
invocant; ie, invoke the method via the reference *without* using a '.'.
If this is possible (and I think it is), it's not (yet) clear what the
syntax would be.  Maybe
$ref(Foo.new():)
 --scott

shotgun Diplomat Leitrim Columbia PBFORTUNE planning operative Hager 
KUBARK Suharto AEFOXTROT ZPSEMANTIC KUFIRE Yeltsin AK-47 immediate
 ( http://cscott.net/ )