mparlak / Flee

Fast Lightweight Expression Evaluator
624 stars 119 forks source link

Allow evaluating void return methods #95

Open huantianad opened 2 years ago

huantianad commented 2 years ago

Allow for the evaluation of methods which return void purely for the side effect, possibly under an option.

Not sure how actively maintained this project is any more, I do see @hunkydoryrepair has a more active repo with some bug fixes, but not sure if this one is active anymore.

hunkydoryrepair commented 2 years ago

I'm not sure your suggestion makes sense. How would you use a void method in an expression? Only the code necessary for evaluation is run. Can you give an example? You can always create you own methods that have a side effect and then return a value (ie. return this).

huantianad commented 2 years ago

Yeah my workaround has just been to return null. My use case is generally evaluating a method directly, for example, I could want to evaluate an expression like Console.WriteLine(1 + 1), which I'm only calling to evaluate the insides of the function and print it into the console (probably not something I would do).