DIP 50 - AST macros

Jacob Carlborg doob at me.com
Tue Nov 12 05:50:49 PST 2013


On 2013-11-12 10:20, Walter Bright wrote:

> For example, the Linq example in the DIP is not compelling, as
> aesthetically nicer code can be written using D's ranges and algorithms:
>
>      auto data = arr.filter!(x => x > 5).array;

I was actually not the one that added the Linq examples. I like the 
above better. I've used a similar example as well:

auto person = Person.where(e => e.name == "John");

Translates to:

select * from person where name = 'John'

But I don't see how that can currently be done in D. Operator 
overloading in D isn't flexible enough. For example, when implementing 
opEquals, you don't know if it's "==" or "!=" that's being called. Same 
with the comparison operators.

> I see no compelling advantage in trying to make D code look like C#; to
> be blunt it's like the old:
>
>      #define BEGIN {
>      #define END }
>
> macros used in old C code to make it look like Pascal.

I agree with this.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list