Skip to content

implicit this reference #232.#233

Merged
davideicardi merged 5 commits intodynamicexpresso:masterfrom
ealeykin:feature/implicit-this-reference
Mar 22, 2022
Merged

implicit this reference #232.#233
davideicardi merged 5 commits intodynamicexpresso:masterfrom
ealeykin:feature/implicit-this-reference

Conversation

@ealeykin
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

Comment thread README.md Outdated
Comment thread README.md Outdated
@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