Skip to content
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

Interpreter Scope identifier support #232

Closed
ealeykin opened this issue Mar 19, 2022 · 2 comments
Closed

Interpreter Scope identifier support #232

ealeykin opened this issue Mar 19, 2022 · 2 comments

Comments

@ealeykin
Copy link
Contributor

ealeykin commented Mar 19, 2022

It would be very convenient to add a Scope support into Interpreter. Consider the following snippet:

record Person(string Name, string Gender, int Age);

var interpreter = new Interpreter();

// this is a proposed Scope feature
interpreter.UseScope<Person>();

var person = new Person("Ulrich", "Male", 30);

var lambda = interpreter.Parse("Gender == \"Male\" && Age >= 30"); 

Assert.True(lambda.Invoke(person));

So it looks like a this reference that is implicitly passed when calling class methods.

Although I can pass a person object itself as a variables - this will make the expression more complex i.e. "person.Gender == \"Male\" && person.Age >= 30" what is less convenient and not concise.

@ealeykin ealeykin changed the title Parser Scope identifier support Interpreter Scope identifier support Mar 19, 2022
@davideicardi
Copy link
Member

Yes, similar requirement came up also in the past, like #18 (back in 2014 ;-) ).
I agree that in some context it could be nice, on the other end it could add some complexity in the parser ... If you find some nice way to implement this feature I think it could be added.

ealeykin added a commit to ealeykin/DynamicExpresso that referenced this issue Mar 20, 2022
@ealeykin
Copy link
Contributor Author

closing this one to track further in #233

davideicardi pushed a commit that referenced this issue Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants