-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse and Compile separation #207 #211
Conversation
I had to comment out some tests related to Invoke with named parameters, like omitting the unused parameter or passing out of order parameters etc. Also haven't found out the cause of failing tests related to LambdaExpression option. |
Thank you @halamah . I will study your changes and investigate about failing tests. Can you sycnronize your branch with master (rebase) so that we always compare it with the latest version? cc @metoule Any feedback on this? |
@davideicardi @metoule - I've changed my PR as the initial one was really too cumbersome. Here I've just copy/pasted the interpreter to a new ExpressionInterpreter class with relevant changes. All these is fully backward compatible since the Interpreter class wasn't changed. So having this new ExpressionInterpter + InterpreterExtensions I can do basically the same, but the client has more obvious control over produced Expression. Plus I've just added a simple extension to Eval an expression without even touching an Interpreter class. var interpreter = new ExpressionInterpreter();
var result = interpreter.Eval("x + 1", x => 2);
Assert.Equals(result, 3); |
If If that's not possible, maybe at least create an abstract class that will be the base of both |
Renamed Parameter.Is to Parameter.Create
I've tried both suggestions and
|
OK, I see your point. If I understand correctly, the main issue is the |
Yes, it could. But I'm note quite sure this will be "pretty" or even feasible. Current Lambda implementation stores compiled result and calling Invoke uses that already compiled lambda. Also there is a trick with UsedParameters - the issue this PR comes from (just to remind if a SetExpression text contains input parameter and a parent one doesn't - it won't be propagated). On the other hand ParseResult is a raw parsed Expression (which is the most valuable part of the library) that could be used in numerous ways without compilation. Later if one needs to invoke the expression he must to compile it first. Maybe there is some way to do what you suggest, but nothing comes to my mind so far without breaking backward compatibility. |
@halamah I completely agree on that sentence. It would be nice to split up the parse and compile phase. |
Yes, I checked your PR locally to see if I can find a way to do that :) |
@halamah I couldn't find a way to update this PR, so I created a new one based on this: #216 |
A proposed refactored sample version of DynamicExpresso in terms of Parse and Compile separation.
#207