NFun
NFun copied to clipboard
Allow partial output struct initialization
class Car{
public int Power {get;set;}
public string Name {get;set;}
public int Year {get;set;}
}
var result = Funny.Calc<Car>("{ power = 120 }");// Name and Year are not initalized
the problem is that if we got two types:
car1: {power:int, name:text, year:int}
car2: {power:int}
then car1 is convertable to car2
but that feature allows to convert car2 to car1
Solution:
make special property 'default' for fields
then, for output struct type we may say that all the fields are has this property:
car3: {@optional power:int,@optional name:text,@optional year:int}
the question is - what is lca for car3, car2?
lca(car3, car2) = {power:int,@optional name:text,@optional year:int} #???