What do you use opDispatch for?
none at anon.com
Mon Mar 22 16:11:20 PDT 2010
> On Sun, Mar 21, 2010 at 23:02, BCS <none at anon.com> wrote:
>> My unitted type uses it for it's value<->unit properties to get a
>> single point of definition for each unit:
> Ah, I see, that's nice. You use the received string to feed another
> and generate what you need. Good idea.
> Why did you make OfType opDispatch a static function?
So that "OfType.someunit(val)" becomes a free function.
>> I've also been thinking of a way to build a compile time LINQ like
>> program. If the comparison and boolean operators are overloadable,
>> you could build prepared SQL queries from expressions at compile
>> using(myDatabase.tables.baz.bar) foreach(Row!(int) row;
>> select!("baz.foo").whare(for.a != someInt && baz.c == bar.c))
> If you have a limited number of methods like .whare, why use
> opDispach? (Sorry if my question is naive).
The opDispatch gets used for the .a and .c bits. The above expression would
get translated so that the !=/== expressions just collect values at runtime
and pass them off as parameters of a prepared SQL statement whose string
is built at compile time. For instance the above might result in the following
string literal being used:
"select baz.foo from baz join bar where a = % and baz.c == bar.c"
More information about the Digitalmars-d-learn