On Fri, 11 Oct 2002 14:05:30 -0700, Michael Lazzaro wrote:
> Maybe postfix ! on a class name means to autoinstantiate an object of
> the named class only if/when first accessed:
>
> our FancyCache $cache; # declare, but leave undef
> our FancyCache! $cache; # undef, but new() it if/when we need
>it
> our $cache returns FancyCache!; # the same
>
> (That's just a joke. Um, I think. Hmm...)
Apart from the "auto" bit of "autoinstantiate", that's almost what it means
in Eiffel, except there it's a prefix !! operator. Actually, you can specify
a subclass between the two shrieks, but perl lets you do that by sticking
Class:: on the method name, which means we'd only need one shriek:
# ! is the new .=
our FancyCache $cache; # declare but leave undef
our FancyCache $cache ! new; # create new instance
our FancyCache $cache ! ReallyFancyCache::new; # create subclass instance
Eiffel does let you omit the name of the constructor if there is a single
argumentless constructor, but Eiffel constructors are all marked as such,
which (at least so far) Perl6 constructors aren't.
--
Peter Haworth [EMAIL PROTECTED]
"The Hotmail migration is becoming the IT equivalent of painting-the-Forth-
bridge, evidently. Once you've think you've finished migrating one end, more
FreeBSD boxes reappear at the other. So you have to start all over again."
-- http://www.theregister.co.uk/content/28/23348.html