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

implicit this reference #232. #233

Merged

Conversation

ealeykin
Copy link
Contributor

@ealeykin ealeykin commented Mar 20, 2022

Allows to implicitly access this identifier set either as a Variable or passed as a Parameter to have more concise expression.

In other word an emulation of this implicit argument passed to a method call.

const string Name = "John";
var context = new KeyValuePair<string, string>(nameof(Name), Name);
var interpreter = new Interpreter().SetVariable("this", context);

Assert.AreEqual(Name, interpreter.Eval("this.Value"));
Assert.AreEqual(Name, interpreter.Eval("Value"));

or

const string Name = "John";
var context = new KeyValuePair<string, string>(nameof(Name), Name);
var parameter = new Parameter("this", context.GetType());
var interpreter = new Interpreter();

Assert.AreEqual(Name, interpreter.Parse("this.Value", parameter).Invoke(context));
Assert.AreEqual(Name, interpreter.Parse("Value", parameter).Invoke(context));

#232

Copy link
Contributor

@metoule metoule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@davideicardi davideicardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

Can you just provide a little note about this feature inside the README documentation?
Maybe inside "Syntax and operators" section? I think it is important to highlight the fact that from now on this will be a special keyword ...

@ealeykin
Copy link
Contributor Author

I would say it's not a special keyword, but rather a special identifier. Please check my latest readme notes commit.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@davideicardi davideicardi merged commit c0f07fa into dynamicexpresso:master Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants