Read-only array reference

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Sun Jul 9 11:02:28 PDT 2006


Hasan Aljudy wrote:
> 
> 
> Bruno Medeiros wrote:
>> Hasan Aljudy wrote:
> <snip proposal>
>>>
>>> So, what do you think about this proposal?
>>> Is it practical? Does it solve most of the const issues?
>>> Does it even make sense, or is it just stupid all-together?
>>>
> <snip>
>>
>>
>> Indeed, if I understood your proposal correctly, I think it is 
>> unpractical, if not down-right senseless. :p
>>
>> Why?
>> Ok, first, what do we want exactly? We want a mechanism that allows us 
>> to specify a readonly contract for a variable, that is, declare a 
>> variable (or function parameter) that should be a "read-only view" 
>> (using Andrei Alexandrescu's term) of another data/object.
> 
> No, if you check my proposal, it was a reply to kris's statement:
> "this whole discussion is basically about array types, since others can 
> happily be passed by value anyway."
> 
> and that is also my understanding.
> 

If that is your premise,then that system would work for it, but I don't 
agree with such a premise. I have to say I didn't understand Kris's 
context in the surroundings statements, like the "Using an aggregate 
(struct or class) instead would give you the /propogation/ aspect 
required. This is in contrast to Walter's proposal, but requires the use 
of aggregates rather than, say, an array.", but in any case it seems to 
me an immutability mechanism is needed for any kind of reference type, 
like Objects too, not just arrays.
I mean, if I have a function that has an Object parameter and I want to 
specify and enforce that the Object should not be changed in the 
function, what am I supposed to do?


>>
>> BTW, Javari is the Java modification described in that paper, which 
>> has reference immutability added to the Java language.
>>
> 
> I need to ask .. what did javari *really* add to java?
> Is there something that's impossible with java but possible with javari?
> 
> ..
> ..
> ..
> 
> no?
> I thought so.

Impossible? No, not in the strict sense.
But "better", "more powerful", "more expressive", etc., then yes, in my 
opinion it does.

Do refrain from using the word "possible" in comparisons between 
languages. You'll be asking for the typical reply that any Turing 
complete language can do the same things as any other such language, so 
we might as well be using Assembler.

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d-learn mailing list