TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote:
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!
But Newname is not declared yet!
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);
I don't understand your point. Are you thinking of .callwith or
postcircumfix<( )> methods on the Code object?
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.
That doesn't look like Perl 6 at all. The parens after class foo is not
part of the grammar. I think what you are showing on the second line
would be a definition for method new inside of class foo. I get you're
trying to explain how subs are like classes, but I'm not following.
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.
Type as a list operator is type conversion. The parens are just
grouping, as in any list operator. Type<blah> would mean Type{'blah'}
from the usual correspondence of <> indexing to hash indexing without
quotes. Likewise you also have the frenchquote form which is the same
with interpolation. So that doesn't mean anything in the situation, but
<> are "taken" in a sense.
--John