[Vala] Immutable ref-counted objects?
- From: Jim Peters <jim uazu net>
- To: vala-list gnome org
- Subject: [Vala] Immutable ref-counted objects?
- Date: Wed, 23 Mar 2011 06:55:06 -0500
Java has partial support for immutable GC'd objects by marking all
public variables in the class as 'final'. So long as all the
referenced objects are also immutable objects, then everything works
out. The objects can be freely passed around without fear that some
caller will modify something and break some other distant code's
assumptions.
The pattern is that the object's external appearance is fixed after
construction. If it needs complex setup, that is done via a mutable
'builder' class passed to the constructor (e.g. StringBuilder ->
String in Java).
Can I do this in Vala at all?
Or if this isn't the 'Vala way' is there something equivalent?
I looked at:
- 'const' in place of Java's 'final': doesn't allow modification after
compile-time
- [Compact] [Immutable]: copied, not ref-counted
- Properties with get; private set;: seemed a little heavy for this,
but maybe all the extra calls would optimise away? Is this the best
approach?
I'm sure I just have to find the right idiom.
Thanks --
Jim
P.S. I'm pleased to have found Vala. You've implemented a lot of my
long-time wished-for features in a "low-level but high-level"
language.
--
Jim Peters (_)/=\~/_(_) jim uazu net
(_) /=\ ~/_ (_)
UazĂș (_) /=\ ~/_ (_) http://
in Peru (_) ____ /=\ ____ ~/_ ____ (_) uazu.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]