Operator overloading

Denis Koroskin 2korden at gmail.com
Tue Dec 23 14:23:51 PST 2008


On Wed, 24 Dec 2008 00:01:20 +0300, Ary Borenszweig <ary at esperanto.org.ar> wrote:

> dennis luehring escribió:
>>> ...
>>> This translation is quite awful and unreadable. It would be so much  
>>> better to get:
>>>
>>> Query query = Select(a).Where(id == 5);
>>  what speaks against an sql parsing mixin?
>>  would be more expressive, compiletime based and typesafe
>> and even far more be able than what you can do with operator overloading
>
> Autocompletion and syntax coloring.

And some compile-time checks (so that you don't mistype your tables/columns):

enum Artists
{
    Id,
    Name,
}

enum Albums
{
    Id,
    Name,
    ArtistId,
}

enum Songs
{
    Id,
    Name,
    AlbumId,
}

auto request = Select(Songs.Id, Songs.Name).
			From!(Artists).
				InnerJoin!(Albums).OnEqual(Albums.ArtistId, Artists.Id).
				InnerJoin!(Songs).OnEqual(Songs.AlbumId, Albums.Id).
			Where(Artists.Name).EqualsTo("Beatles").
			And(Albums.Name).EqualsTo("Yellow Submarine").
			OrderBy(Songs.Name).
			Limit(0, 1);

Just an example :)



More information about the Digitalmars-d mailing list