Hi, I'm sorry for my noobies beforehand.
I'm trying to make an API to code generation, so some "variable objects" has to have behavior close to normal python vars just to avoid extra-typing of end-user.
With standard methods overriding all is fine, but in case of retrieving the value, or assigning it I found some "syntax" problems.
For example, the first redaction used __call__ method as sort of descriptor. so, syntax looked:
Also, things start to be ambiguous for such cases:
So, with the new version, I'm looking to descriptors, but even with first "callable" problem solved I found the second problem alive.
Example:
more than, with descriptors, there is no "syntax-defense" of making something terrible:
I'm trying to make an API to code generation, so some "variable objects" has to have behavior close to normal python vars just to avoid extra-typing of end-user.
With standard methods overriding all is fine, but in case of retrieving the value, or assigning it I found some "syntax" problems.
For example, the first redaction used __call__ method as sort of descriptor. so, syntax looked:
> my_var() val > my_var(1) > my_var() 1but it starts to be uncomfortable with usage of callable() and seemed functions.
Also, things start to be ambiguous for such cases:
> var2(1) > var2 += 1 # here we can use methods of var2 > var1(var2) > var1() 2 # here we can NOT use methods of var2 var1(var2())and it was not so good to handle inside values of variables but not references to variables themselves in some cases.
So, with the new version, I'm looking to descriptors, but even with first "callable" problem solved I found the second problem alive.
Example:
> var1.val = 1 > var2.val = 2 > var2 += var1 > var2.val 3 # nasty > var2.val = var1 > var2.val 1How would You solve this case?
more than, with descriptors, there is no "syntax-defense" of making something terrible:
var1.val = 1 var2.val = 2 var1.val = var2 # here code is being generated var1 += 1 # here wrong code is being generated var1 = var2 var1 += 1 # here no code is generated var1 = var2.val var1 += 1