Steve Simmons wrote:
> I really like the idea of constants in perl, but think the RFC should
> go a lot further. C/C++ has solved this problem; we should follow in
> their footsteps.
> <...>
I desparately _don't_ want to follow the horrible mess that is const in C++.
The enormous hassle in trying to do any sensible optimisation on C++'s
consts has been a real nightmare. Trying to find a way of adding a
'restrict' keyword which actually does something useful has been just as
bad. For why guarantees of aliasing and constness are important, see for
example:
http://oonumerics.org/oon/oon-list/archive/0328.html
> The same sort of thought process should be applied to lists, arrays,
> references, and objects. IMHO the RFC should be updated to reflect
> all these issues before we can properly consider it. Sorry to rain
> all over your parade, Jeremy. The core idea is great, but the
> implementation section really needs expansion.
>
It's not like that! An RFC is the start of a discussion, not the last
word... Your interesting ideas are not 'raining on my parade'--they're very
constructive thoughts and I really appreciate them. This is certainly an
area I've been thinking about--as I said in an earlier post:
<quote>
Yes. But what about types and attributes within complex types?
- Constant refs vs refs to constants?
- Types of hash (or 'pair') keys and elements?
- Attributes (e.g. constantness) of hash keys and elements?
- Ditto for arrays/lists...
I left this out of v1 of the RFC because I wanted to get some feedback on
syntax. If we can flesh this out I'll incorporate it into v2.
</quote>
My current thinking is that a ref to a constant should only be possible
through creating a constant first, and then creating a reference to that
separately. I'm still unsure of array and hash elements, however. Using the
':' in this way has the potential to cause ambiguity with list generation
syntax (RFC 81), and add complexity where there may not be much payoff.
I really need to see some examples of code where this would be of practical
benefit, I think.