Mark J. Reed |Perl 6| wrote:
On Mon, Apr 14, 2008 at 2:32 PM, Jonathan Worthington
 my Dog $fifi .= new(); # works in Rakudo too ;-)

And even in Pugs! :)  Doesn't help with literals, though, e.g.

my Float $approx_pi = 3.14;

So the idea of marking the use of implicit type would be better than making it automatic in some cases and not in others. Logically, that is just a symbol like ::?TYPERHS but with more syntactic sugar, such as a special symbol:

 my ☂ $approx_pi = 3.14;

Where the umbrella is meant to convey the protective nature. For those who don't have umbrella keys on their keyboards, you might consider the useless "window" buttons near the spacebar, or invest in one of these ( More seriously, reusing existing symbols and concepts, a generic type is introduced using ::T, in a signature. The stuff after 'my' is actually a signature, so if

  sub foo (::T $a)

actually works (⦃and it might not -- still need to hear from Larry about leaving off the other type, you might have to write sub foo (Any ::T $a) ⦄
Then the declaration

  my ::T $x = whatever;

should use the exact same generic mechanism!  At worst, it needs

  my Any ::T $x = whatever;

and it will introduce the T symbol at that point based on the actual type of what gets initialized.


Reply via email to