-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Description of ismonom algorithms? #94
Comments
Hi Matthew, From the start of this work, this implementation has reflected the theory from Featherweight Go as much as possible. At some point, we formalised a graph-based algorithm for the nomono check but this ended up being impractical to prove correctness results. I suppose @rhu1 implemented that attempt (he can confirm). What you suggest sounds fine to me. I suppose you would apply this algorithm from each declaration (types and functions), right? That is basically what Fig. 23 in the paper does (modulo added complication because we support type params in methods). But essentially, Fig 23 computes the the call graph starting from any declaration, tracking type variables were declared (e.g, T), then it raises an error if a cycle includes a type variable that occurs under a type constructor (e.g., Box[T]). Happy to talk more if you need help understanding that bit of the paper -- I know the greek letters don't help! J. |
Hi @mdempsky |
Thanks very much for the responses and background context on the algorithms you used.
In Go, the package dependency graph has to be acyclic and methods must also be declared in the same package as their receiver type. So unless I'm misunderstanding your question, no, it's not possible to have mutually referential declarations across packages. |
Hello, I'm trying to understand the algorithms used in https://github.com/rhu1/fgg/blob/main/internal/fgg/fgg_ismonom.go.
My first instinct for detecting non-monomorphisable code was to implement a "data" flow analysis algorithm for tracking which type parameters are used as type arguments for instantiating other generics, and then looking for cycles. It seems like this might be similar to the "old CFG-based test" included at the bottom of the above file. Is there a reason why that test was deprecated in favor of the transitive closure algorithm?
Concretely, the algorithm I had in mind was:
F[T]
) and with positive weight if the type parameter is used within a composite type (e.g.,F[*T]
orF[[]T]
).I think this algorithm can be applied to each package. We don't allow anything like C++'s template template parameters, so I don't think non-monomorphisable cycles can appear across packages.
Thanks.
The text was updated successfully, but these errors were encountered: