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
Instead of having ColorGraph = MetaGraph, would it be possible to have ColorGraph = MetaGraph(Int64, ...), and thus ensure it is not possible to pass in an unrelated MetaGraph into consume_colors?
First of all, argument annotation and output annotation have different behaviors:
argument annotations prevent the method from accepting anything else
output annnotations will try to convert the result if it doesn't have the right type
My take is that output annotations are rarely necessary when you constrain the arguments on downstream methods anyway. With that in mind, you could use the full type of g as a type annotation, but it is rather convoluted and there is one type parameter (the var... at the end) which is a MetaGraphsNext internal.
First of all, argument annotation and output annotation have different behaviors:
* argument annotations prevent the method from accepting anything else
* output annnotations will try to convert the result if it doesn't have the right type
My take is that output annotations are rarely necessary when you constrain the arguments on downstream methods anyway. With that in mind, you could use the full type of g as a type annotation, but it is rather convoluted and there is one type parameter (the var... at the end) which is a MetaGraphsNext internal.
Activity
gdalle commentedon Oct 6, 2025
Output type annotations are seldom used in Julia, can I ask why you want to do this in the first place?
gdalle commentedon Oct 8, 2025
Also, could you provide a complete runnable example? Here I'm not sure whether
CustomGraphis meant to be a type or an object?lenianiva commentedon Oct 9, 2025
I want to pass values with the
CustomGraphtype into other functions. I'm only using the output type as an example.CustomGraphis meant to be a type.gdalle commentedon Oct 9, 2025
Can you give a complete code example? Usually you would rather constrain the input types of other functions for dispatch purposes.
lenianiva commentedon Nov 23, 2025
e.g.
Instead of having
ColorGraph = MetaGraph, would it be possible to haveColorGraph = MetaGraph(Int64, ...), and thus ensure it is not possible to pass in an unrelatedMetaGraphintoconsume_colors?gdalle commentedon Nov 24, 2025
First of all, argument annotation and output annotation have different behaviors:
My take is that output annotations are rarely necessary when you constrain the arguments on downstream methods anyway. With that in mind, you could use the full type of
gas a type annotation, but it is rather convoluted and there is one type parameter (thevar...at the end) which is a MetaGraphsNext internal.So if I had this problem, I would probably define
and skip the internal weights type parameter, especially if you don't use it.
lenianiva commentedon Nov 26, 2025
This solution is perfect! Thank you.