But this is not the same thing. AFAIK, this is not possible yet as a Base 
class. But I'm far from knowing everything.

I've seen discussions about providing a way to inherit default methods from 
a field of a composite type but I can't find them. One problem of the 
method is type preservation. But whatever, you could still do that and set 
the methods appropriately. This would be tedious but should work: all you 
have to do is to not set a setindex! method for your new type.

Or you may want instead to inherit from AbstractArray and define everything 
missing from there and again, set setindex! to something else for your new 
type. I've never done it, I don't know what it would require to make that 
working.




While I would love to see immutability by default on variables which would 
avoid a whole class of bugs and inefficiencies for a modest cost (except 
maybe in the global scope for the REPL? or maybe that would solve the 
global scope efficiency problem?), I'm more sceptical about immutable 
arrays/dict. Not because it is not sensible, but because if someone is 
tempted to change one of your array values, nothing can
prevent him to do so (in Julia and in many other languages).

My take on this would be to go for the composite type and prefix the 
private things with "private" or "_" or whatever and add a comment stating 
that this should never be accessed directly.

Reply via email to