> Ick. I don't want to lose the dots that visually distinguish instance > variables from ordinary lexicals, and simultaneously render the extra > bracketing and indentation unnecessary. I'd write the above as: > > class Demo; > > my $.foo is public; > my $.bar; > > method INIT ($fooval, $barval) { > $.foo = $fooval; > $.bar = $barval; > } > > If you want to limit the scope, you can always bracket around the whole > thing, just as with the package declaration. And I'd like "class" and > "module" to just be variants of the "package" keyword. That makes them > easier to teach.
Except that you now have to explain why -- unlike an ordinary my $variable -- the lexical scope of a my $.variable is to the end of its class, not the end of its block or file. :-( Or does the lexical scope of a class extend only to the start of the next class (unlike a package)? And if so, then which way does a module work? And does a module or package close the lexical scope of a class? And vice-versa? :-( Damian