DIP 50 - AST macros
Ellery Newcomer
ellery-newcomer at utulsa.edu
Sun Nov 17 13:15:03 PST 2013
On 11/17/2013 11:41 AM, Simen Kjærås wrote:
>
> Source is attached. I hope God forgives me.
>
I suppose you'd have to do something like
x.Where(OR( NOT(Args.thing = "thing"), Args.sing = "sing"))
for nesting and negation and all that.
I'd wait for walter to relax the restrictions on ==, &&, etc operator
overloading. Then you probably could do
x.Where(X => X.thing != "thing" || X.sing == "sing")
let's see here. If X's type is QueryExp!Entity and the return type is
SomeRange!Entity then querying looks doable.
how about composing expressions? take the result of that lambda EXP,
EXP = EXP && X.cling == 1; // should work fine?
how about decomposing expressions?
EXP = EXP.lhs; // should work fine?
EXP.rhs.rhs.value // returns "sing" - should work fine? the lambda
should create a closure, so we should be able to get out any value we put in
you won't be able to do
x.Where(X => upper(X.thing) == "THING")
without ast macros but will have to be satisfied with
x.Where(X => X.thing.upper() == "THING")
will you be able to do
x.Where(X => X.thing == "THING" && x.Any(X2 => X2.thing == X.thing &&
X2.id != X.id))
?
either "Any" would have to be only for template expressions, or X would
have to be an outer context like so:
x.Where(X => X.it.thing == "THING" && X.x.Any(X2 => X2.it.thing ==
X.it.thing && X2.it.id != X.it.id))
because x.Any(...) should return bool, but inside the query expression
it should return QueryExp. In both cases it would take a param of
QueryExp delegate(QueryExp)
Anybody else have any other ideas?
More information about the Digitalmars-d
mailing list