@property - take it behind the woodshed and shoot it?
Rob T
alanb at ucora.com
Sat Jan 26 14:24:21 PST 2013
On Saturday, 26 January 2013 at 21:48:54 UTC, Artur Skawina wrote:
[..]
>
> Hmm, the current state of them being defined by two separate
> functions really
> isn't ideal. But introducing new keywords or magic identifiers
> just for this
> does not seem right.
>
> class A
> {
> private int i;
> int foo {
> out { return i; }
> in(int v) { i = v; }
> }
> }
>
> or
>
> class A
> {
> private int i;
> @property foo {
> int out { return i; }
> in(int v) { i = v; }
> }
> }
>
> artur
In a more pefect world, we'd redefine what a variable and
function is, merging the two together as one, let the compiler
optimize things appropriately, and make the language issues far
more consistent and simple.
For example, typeof(x) is way too simplistic to be of use when
you have objects that have more than on type. For example, a
property has a setter, getter, and storage type, so what should
typeof(prop) return? It can only tell you one thing out of at
least 3 things, so it's insufficient.
Great for C, useless for D.
We're basically finding ourselves in the same position C++ has
found itself in, where the old concepts are no longer suitable
for a modern language, but there's no practical way to resolve
the situation without redesigning the whole language into a new
one. D tried to make a better C++, and it has done a good job of
that up to a point, but since it has made use of many of the old
paradigms as its base, it can only do so much.
One solution is to not bother trying to add on any extra
complexity that does not fit in.
--rt
More information about the Digitalmars-d
mailing list