On Fri, Feb 16, 2007 at 12:07:43PM -0800, Steve Lukas wrote: : Larry, Smylers, now I've read your answers. : Larry, thanks for telling me that it is already specced. : I have overlooked it, sorry. : Hello Smylers, thanks for your answer, too. I'm not stucked on : the form C<$-name>. I am happy to get the runtime readonly : or the pragma.
The "is readonly" is part of the declaration, and can therefore give you compile-time diagnostics as well as run-time. The run-time check is merely a fail-safe for situations where the compiler can't determine that you're attempting to modify something. That being said, in writing the Perl 6 grammar I keep running into the need for rw context variables. I'm getting tired of writing things like: my @heredoc_stubs is context is rw = () so maybe there's some general syntactic relief for rw/ro that is orthogonal to everything else. But that means it wouldn't be a trait, a type, a sigil, or a twigil, if it's really orthogonal. I don't just want to go with bare rw and ro markers because I think they're too easy to confuse. It's more like we want an initializer that says "lock this after I change it". If used on the initializer of a declaration it would have the force of a readonly declaration. Some variant on or near the =, in other words, that could also be a variant on normal assignment. But maybe it also has to stand alone to declare it as a "write once" variable, I expect. Currently "is readonly" only works on the declaration, and only on items that are initialized by the declaration. Maybe that's good enough for most purposes. This isn't quite what context variables want though. They tend to want to be writeable in the current scope and then either ro or rw in sub-scopes. So I've been wondering whether we should split the "is context" declarator into two, one of which is for passing immutable info downward like environment variables, and one of which is for passing data upward to a mutable target, kinda like the implicit target of a gather. Don't know what the syntax for that should be though. Unfortunately the opposite of "context" is not "pretext", though that's kind of a funny pun--set this variable up ahead of time to gather text. And "protext" isn't a word, that I know of... I guess I need to visit the thesaurus for all the words that mean disseminate and assemble... Other ideas will be gladly entertained before being rejected. :-) Larry