HaloO,
John M. Dlugosz wrote:
sub GetType (-->Type) { ... }
my ::RunTimeType := GetType;
I think my declares value variables which means you need
a sigil:
my ::RunTimeType $ := GetType;
and of course you capture the runtime type of the
return value of GetType. If you write that as
my ::RunTimeType $ := &GetType;
you get the type of &GetType itself that is :(-->Type).
Also, is this the normal way of making typedefs?
my ::Newname := OldTypeName;
I guess not. But
::Newname ::= OldTypeName;
should work. The type system is a runtime overlay to
the value system. This is reflected in the source by
putting types and values into different syntactic slots.
You cannot mix these!
I unify class and code conceptually and Perl 6 might
unify them actually. That is I think invoking a sub
essentially means:
sub foo ($x) {...}
$x = &foo.new(3);
class foo ($x) {...} # constructor syntax?
$y = ::foo.new(3); # perhaps also: ::foo(3)
$z = foo 3; # ambiguous or &foo?
If you wanted more than one constructor you'd need to prefix
it with multi.
BTW, I wonder why S12 is wasting {} for parent class construction:
class Dog is Animal {...}
my $pet = Dog.new( :name<Fido>, Animal{ :blood<warm>, :legs(4) } );
Wouldn't parens be sufficient? Looks like Type{} now means protoobject
construction and Type() means concrete object construction. And Type[]
means type construction. So what exactly can one do with a protoobject?
And what is a protoinvocation of a sub? When is it evaluated?
Finally I wonder why we didn't give a meaning to Type<>? Does that
look too much like C++, C# or Java templates?
Regards, TSa.
--
"The unavoidable price of reliability is simplicity"
-- C.A.R. Hoare