John M. Dlugosz wrote:
But Newname is not declared yet!

No, but that is the same as with other sigiled terms.
You can also do funny things like

  ::*Num ::= Complex;

The spec doesn't define namespaces to be protected in any
way. The above is naturally limited to the compile run,
though. Now the question is what repercussions

  ::*Num := Complex;

has at runtime? Is it allowed? Note that with :: there seems
to be a syntactic distinction between lvalues and rvalues
that other sigils don't have:

  $x = 3;  # x as lvalue
  $y = x;  # x as rvalue

This even doesn't work with code variables

  &x = 3;  # needs {3} or Code 3, but why is that not implicit?
  $y = x;

where I find it quite intuitive. IOW, there are some
intrinsic type checks at compile type.

   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?

No, I think of foo not as a Code object but as a class that
does Code. Invoking foo means instanciating the Code class.
That is the above stores an uninvoked invocation of foo in $x.
Obviously you can invoke it as $x() later to get out what
foo(3) would. I think you can continue this with

  $y = $x + 1;

which has to put an uninvoke invocation of infix:<+> into
$y and so on. You can call that lazy computation. Such an
uncalled computation can be collapsed with $y().

BTW, what is the official syntax for coroutines now?
I see no mention of the yield builtin in S06.

   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.

I try more to describe how bare words work. You can overload the bare
word foo with two things: ::foo and &foo. After first usage with the
sigil it's available without. The & form is even more flexible. It is
provisionally parsed as list prefix. And you can call ::foo as a list
prefix as well. So which takes precedence if both are defined?

Type as a list operator is type conversion. The parens are just grouping, as in any list operator.

But what else should it be than a constructor call?

 Type<blah> would mean Type{'blah'}

No. That would require Type to be a term.

  sub foo {...}

  foo<a>;  # syntax error or special type meaning

  foo <a>; # calls foo with @_[0] := <a>

  foo .<a>; # calls foo with @_[0] := $CALLER::_.<a>

  foo::<a>; # pulls out a from lexical namespace of foo

The last line uses postfix:<::> not sigil:<::>.

Regards, TSa.

"The unavoidable price of reliability is simplicity"
  -- C.A.R. Hoare

Reply via email to