Attributes are per-object.
If an instance attribute is to ever have any value, then it is at best: write-once.
And it is conceivable that a factory constructor could derive from different base classes to provide different constant attributes.
Constants are per-process.
Actually, Perl's constants are per-package rather than per process. And it certainly isn't inconceivable that they could be implemented to be block scoped as many of the newer pragmas are.
And as I understand it, it would be completely possible to have per-instance constants with Perl 6 using Roles. Maybe even in Perl 5 with Perl6::Roles
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
If an instance attribute is to ever have any value, then it is at best: write-once.
I've never heard people say constants are write-once rather than read-only, yet the same applies to them.
Yes, I did say "read-only" attributes are «more "write-once" than "read-only"» earlier, but I now think that was a mistake.
Actually, Perl's constants are per-package rather than per process.
For each definition of an attribute, there is one value per object.
For each definition of a constant, there is one value per processinterpreter.
I have no idea what you think is per package.
| [reply] |
I've never heard people say constants are write-once rather than read-only, yet the same applies to them.
Oh dear. You've moved into let's defend the indefensible mode again.
Constants are 'set' at compile time. Write-once attributes are assigned at runtime. That is a very clear distinction.
Not as clear as in a compiled language in as much as they are not loaded from the process image into hardware-protected read-only memory segments. But sufficiently intractable to even deliberate meddling; and with sufficient performance benefits; to make the distinction obvious.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
At least C++ has an ISO standard with precisely defined nomenclature. Most people don't use it that carefully, but the formaism can be trotted out and used when necessary.
| [reply] |