On Thursday, January 9, 2003, at 03:24  AM, Damian Conway wrote:
Michael Lazzaro asked:
   class FileBasedHash is Hash { ...stuff... };
   my %data is FileBasedHash('/tmp/foo.txt');
Yes.

   my $path = '/tmp/foo.txt';
   my %data is FileBasedHash($path);
Indeed
Great -- then I have only one more question, I think. In the words of a certain cartoon character, what's *this* button do?

my $b is $a;

My presumption:

1) If C<my $a = MyScalar>, e.g. $a is set to a class name, it's saying that $b is implemented by a MyScalar. But I don't know if these two lines would really have the same result, given rule (2), below:

$a = MyScalar;
$a = 'MyScalar';

2) If C<my $a = $fooObj>, e.g. it's set to an arbitrary object instance, it's saying that $b is implemented by the object instance in $a. So these statements are equiv:

my $a = FileBasedHash.new($path);
my %b is $a;
vs.
my %b is FileBasedHash($path);

If the object in $a doesn't implement the Scalar interface, it's a runtime error. And note that C<my %b is %a> would be a runtime error, one would hope.


MikeL

(My original gut desire was that C<my $b is $a> be the ultracool perl6 way of achieving prototype-based (classless) OO, such that $b inherits its base functionality from $a. As inherently cool as that is, I don't think that can possibly work, and it would conflict *severely* with these other meanings. Ah, well.)



Reply via email to