Re: A12: Required Named Parameters Strike Back!

2004-04-22 Thread John Siracusa
On 4/22/04 6:52 PM, John Siracusa wrote:
> Yes, it appears that runtime checks for the existence of required params
> will continue to be a necessary part of Perl programming.

...of course, there are at least two ways to do "runtime checks":

* runtime checks that the programmer has to write himself

* runtime checks that the compiler generates automatically
  (presumably using a trait like "is required")

I'm sure someone will write the latter if it's not part of the core
language...hint hint :)

-John



Re: A12: Required Named Parameters Strike Back!

2004-04-22 Thread John Siracusa
On 4/22/04 5:33 PM, Aaron Sherman wrote:
> On Tue, 2004-04-20 at 10:51, John Siracusa wrote:
>> Hm, so how would the "is required" trait that Damian posted work?  Would it
>> simply be shorthand for a run-time check that I don't have to write myself?
>> I was under the impression that it would work the way I described earlier:
>> 
>> sub foo(+$a is required, +$b is required) { ... }
> 
> Your example is a non-multi sub, which AFAIK means that you can do this
> at compile time. But for multis and methods, I think Larry and Dan's
> comments still hold.
> 
> The likelyhood that P6.0.0 will make this distinction is another thing.
> I'd rather have a language that works than one that is complete. Plenty
> of time to complete it later, but those who are thinking of taking on
> large-scale development with it (e.g. converting over large CPAN modules
> or implementing new Perl6ish libraries) just want something that runs :)

Yes, it appears that runtime checks for the existence of required params
will continue to be a necessary part of Perl programming.  I suppose a
saving grace is that Perl 6 will support "real" assertions that disappear
entirely from the program flow when a switch is flipped.

-John



Re: A12: Required Named Parameters Strike Back!

2004-04-22 Thread Aaron Sherman
On Tue, 2004-04-20 at 10:51, John Siracusa wrote:

> Hm, so how would the "is required" trait that Damian posted work?  Would it
> simply be shorthand for a run-time check that I don't have to write myself?
> I was under the impression that it would work the way I described earlier:
> 
> sub foo(+$a is required, +$b is required) { ... }

Your example is a non-multi sub, which AFAIK means that you can do this
at compile time. But for multis and methods, I think Larry and Dan's
comments still hold.

The likelyhood that P6.0.0 will make this distinction is another thing.
I'd rather have a language that works than one that is complete. Plenty
of time to complete it later, but those who are thinking of taking on
large-scale development with it (e.g. converting over large CPAN modules
or implementing new Perl6ish libraries) just want something that runs :)

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback




Re: Apo 12

2004-04-22 Thread Aaron Sherman
On Mon, 2004-04-19 at 12:18, Larry Wall wrote:
> On Mon, Apr 19, 2004 at 11:44:24AM -0400, Dan Sugalski wrote:
> : For that they leave it to lambda.weblogs.com to heap *educated* scorn 
> : and derision on things. :)
> 
> Hmm, well, in all their educatedness, they don't seem to have figured
> out that the prototyping behavior they're looking for is actually
> supplied by wildcard delegation in Perl 6...

Well, I think to be fair, it's going to take a long while for most of
the world to digest A12 and figure out how it does or does not deliver
their pet features / paradigms.

Prototyping in P6 would seem to me to be easy, but not quite the
default. You'd want an intermediary that did the MetaClass negotiation
as you "derived" from an existing object. Or will that be in the core?
Can you say:

my Object $obj1;
MyClassExtenderClass.add_a_print_method($obj1.metaclass);
my ::{$obj1.class} $obj2;

?

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback




A question about binary does

2004-04-22 Thread Abhijit A. Mahabal

This is actually a couple of questions:
1: can you extend roles by saying: role Set is extended {}
2: if yes, does this change variables for which you said  $var does Set?
In other words, is the singleton class like a closure or a first-class
class?

What follows is just some example code in case my question is vague.

--Abhijit

role Set{
  method add ($elt) { $self.{$elt} = 1  }
  method remove ($elt) {...}
  method intersection($other where Set) {
# can I write that as: method intersection (Set $other) ?
return $self.keys.grep { exists $other{$^a}  }
  }
}

class Set_class does Set {}

class Collector{
  has %.coins does Set;# brand new singleton class
  has Set_class %.stamps;  # use existing class
}

my Collector $collector .= new;
$collector.coins.add(new Coin());   #okay
$collector.stamps.add(new Stamp()); #okay

# much later during compilation

role Set is extended{ # is this: die if any collision in any class
  method difference ($other where Set) {...}
}

$collector.stamps.difference(...); # okay
$collector.coins.difference(...);  # Is that legal?

# In other words, is the singleton class like a closure or like a
first-class class?

Abhijit A. Mahabal  http://www.cs.indiana.edu/~amahabal/



Re: A12: Strings

2004-04-22 Thread Aaron Sherman
On Wed, 2004-04-21 at 01:51, Larry Wall wrote:

> Note these just warp the defaults.  Underneath is still a strongly
> typed string system.  So you can say "use bytes" and know that the
> strings that *you* create are byte strings.  However, if you get in a
> string from another module, you can't necessarily process it as bytes.

But, what happens if I:

{
use bytes;
my string $line = $filehandlelikething.getline;
}

Does my saying "string" enforce anything, or do I have to:

{
use bytes;
my string $line is bytes = $filehandlelikething.getline;
}

?

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback