Forums

const / readonly member

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: const / readonly member

Postby hopscc » Sat Feb 14, 2009 3:50 am

Theres a patch pending acceptance on ticket:100 implementing readonly.
Its implemented as an accessmodifier ( named 'final') rather than a keyword

Java doesnt have (c# equiv) const - its final variables act like c# readonly, (static) final variables may be computed statically at compile time if possible

The promise cobra makes as to the meaning of const vs readonly/final ( if directly supporting both) is going to be a bit weaselly depending on the back end support for
the same concepts.
Hence I'd suggest promising direct support for runtime initted constants with the (weaker) promise of best effort for compile time support if supported by backend
(const keyword, combinatorial for weaker promise) worst case is that you only get readonly equivalent which is probably most desirable situation anyway.

I dont see val/value as being significantly better than const for indicating some form of variable immutability, much the reverse in fact ( same as var)

perhaps we could go for a more truthful keyword 'as_const_as_we_can_get' ( acawcg) for indicating the constantness cobra is providing :)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: const / readonly member

Postby Charles » Tue Feb 17, 2009 4:12 pm

Perhaps we can still support the "const" semantics even on the JVM since this is a function of the compiler. In other words, it could read the value from the JVM package that is referenced and then inline it.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 80 guests