Chris Dutton wrote: > Seeing this, an idea mildly Eiffel-ish comes to mind. Could we get away > with something like the following? > > method set_baz(type($.baz) $newbaz) { $.baz = $newbaz }
I'm not sure that Larry has considered precisely what can be used as a type specifier in Perl 6. Your proposal seems very perlish to me so I would hope so. Of course, this would imply that C<type> was an compile-time function, which doesn't sit well with Perl's predominantly run-time typing. So it would seem likely that there would need to be both compile-time and run-time versions of C<type>, or at least distinct compile-time and run-time semantics. In which case one might need to write: method set_baz(BEGIN{type($.baz)} $newbaz) { $.baz = $newbaz } That's getting a little ugly, so maybe we'd "lift" the syntax from Eiffel instead: method set_baz($newbaz is like($.baz)) { $.baz = $newbaz } Hmmmmmmm. Damian