ExpressionEvaluator icon indicating copy to clipboard operation
ExpressionEvaluator copied to clipboard

Named arguments support

Open ko-vasilev opened this issue 4 years ago • 2 comments

Hello, Couldn't find anything about this - but is there a support for named optional arguments in function calls? Here is something I'm trying to do:

public class Program
{
	public class Ctx
	{
		public double Subtract(double x = 0, double y = 1)
		{
			return x - y;
		}
	}
	
	public static void Main()
	{
		ExpressionEvaluator evaluator = new ExpressionEvaluator();
		evaluator.Context = new Ctx();
		
		string expression = "Subtract(y:2)";
		
		Console.WriteLine(expression);
		Console.WriteLine(evaluator.Evaluate(expression));
		Console.WriteLine(string.Empty);
	}
}

So I'd expect to be able to use named argument just like in C#, is there a support for that? If no, do you have any plans for implementing it?

Thank you.

ko-vasilev avatar Jul 20 '21 05:07 ko-vasilev

Hello @ko-vasilev. Thanks for this issue. For now named arguments are not supported. I think it could be nice to have. I am on vacation for the next 2 weeks. I will look how to implement it when I come back.

codingseb avatar Jul 20 '21 08:07 codingseb

@codingseb enjoy your vacation :)

lofcz avatar Jul 20 '21 11:07 lofcz