Reddit: why aren't people using D?

Michel Fortin michel.fortin at michelf.com
Fri Jul 24 20:05:13 PDT 2009


On 2009-07-24 17:40:37 -0400, Walter Bright <newshound1 at digitalmars.com> said:

> It's just that D is complex enough - there needs to be some very good 
> reasons for adding more syntax that has apparently zero semantic 
> information that would be different from the usual function syntax.

You know. I agree with you on that point. Earlier, in a thread no one 
replied to [1], demonstrated that we already have almost everyting we 
need to create properties using mixins. Here's an example:

	struct Z
	{
		int valueSquare;

		template Property()
		{
			int value;

			void opAssign(int v) { value = v; valueSquare = value * value; }
			void opAddAssign(int v) { value = v; valueSquare = value * value; }
			int get() { return value; }

			alias get this;
		}

		mixin Property property;
	}

The only really missing part is that "alias get this" doesn't work 
("Error: expression has no value" when fetching a value from 
z.property) so you have to explicitly call the "get" function.

[1]: 
http://www.digitalmars.com/d/archives/digitalmars/D/properties_using_template_mixins_and_alias_this_87952.html

-- 


Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list