On Wed, 9 Oct 2002, Michael Lazzaro wrote: > PLEASE contribute to this document! Email me with suggestions, "yes" > or "no" votes on recipe approaches, info on philosophies or best-guess > syntax, etc., or discuss them here on perl6-language.
Very nice. I hope this evolves into a useful perl6 reference. Here are some comments on section 1. Recipe 1.6 my $obj = MyClass.new(...); # synonymous, if ... is empty Yes. my $obj = MyClass(...); This seems to assume that objects have a default method if you treat them like a subroutine. Kinda tcl-ish, but I don't recall anything like this in the apocalypes. my $obj = MyClass; I think $obj would contain a reference to MyClass, not an instance of MyClass. my $obj is MyClass; # similar to above, but autovivifying? This declares $obj as a MyClass, but does not instantiate it. If I recall the discussion on this subject, the preferred syntax was my $obj is Myclass .= new(...); Notice that you still have to explicitly invoke the new method. The "is MyClass" merely prevents you from assigning a non-MyClass value to $obj. The difference between "my $i is int = 3" and "my $obj is MyClass = MyClass.new" is that "3" is already an instance of int. MyClass does not have a textual representation which the compiler will recognize unless you perform some source filtering/lexical rules tricks. The theory about being "autovivified according to the default constructor" is nice, but I think it is not true. If you do not explicitly assign a value to a variable (number, string, or object), it gets a value of undef. Autovivification refers to the automatic creation of the *variable*, not the value. If you use a variable before declaring it, the variable is created with a value of undef. Similarly, if you use a hash or array item which does not exist, it is autovivified with a value of undef. Recipe 1.10 & 1.11 Issue: Or can you? In perl5, class methods are the same as instance methods. The difference is that they receive a class reference as $self instead of an object instance. (perl5 class references happen to be strings, but we won't hold perl6 to that.) So it is not yet known whether class methods in perl6 will have any greater distinction from instance methods than that. Recipe 1.15 I think the thought here was to use the binding operator. my ClassAlias := MyClass; ~ John Williams