You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt"
)
func main() {
a := myFloats{1.0, 2.0, 3.0}
fmt.Println(a.First())
}
//go:generate pie myFloats.First
type myFloats []float64
yields
./myfloats_pie.go:5:11: ss.FirstOr undefined (type myFloats has no field or method FirstOr)
Currently, the developer hits this error and figures out they must explicitly ask for FirstOr:
//go:generate pie myFloats.First.FirstOr
It would be nice if Pie somehow knew it requires to generate FirstOras a dependency for First. I'm not saying this is trivial though, and also the inconvenience is minor.
The text was updated successfully, but these errors were encountered:
Generating all Pie functions with //go:generate pie myType.*
seems to be the best choice in general.
My measurements confirm that the final compiled binary is not bigger when lots a unused functions are generated. Unused funcs are correctly discarded by the compiler.
Ah, that's a good catch. I have thought before about how to handle this because there are several other cases where some functions would be easier to implement if they could use other functions that may not be included.
One solution I can think of right now is to add dependencies when registering the functions:
yields
Currently, the developer hits this error and figures out they must explicitly ask for
FirstOr
:It would be nice if Pie somehow knew it requires to generate
FirstOr
as a dependency forFirst
. I'm not saying this is trivial though, and also the inconvenience is minor.The text was updated successfully, but these errors were encountered: