Closed jbl428 closed 3 years ago
Wow what a great catch. Hopefully this is only slightly tricky and relatively low effort to fix for someone.
@awalterschulze I have tried solve this issue. but there are multiple approach and i am not sure which one is best.
Zero
value if black identifier is given.It would be nice if you could give me your opinion. 😄
Please ignore first one.
Because people can use generated code with multiple functions (with and without black identifier), first one is not a perfect solution.
Yeah I kind of also wanted number 1 (Zero) to work, but I think you are right. I think number 2 is best: make random parameter name that does not conflict other parameters and replace blank identifier. We want the generated code to be as close as possible to handwritten code that is readable. So I think it is important to keep this random parameter name as short as possible, but this is also the reason to exclude option 3, because p0, p1, p2 is not what a human would probably write.
Maybe it would be nice to create a function that takes in a type signature for a function and returns the same function but with blank identifiers renamed. This way it is easier to test and most of the existing code can stay the same, except for also calling this function. What do you think?
I agree with keeping the handwritten code as much as possible. And maybe we can rename that blank identifier to meaningful one, not ugly random string.
I think it is good place to create the function you mentioned in derive/types.go What do you think?
That could work or even better start a new file called params.go
Given the following test code
goderive
generates the following codeIt has compilation error.
I think these plugins have this issue.