Open nsajko opened 7 months ago
There is a hidden field of MethodTable that can be set to enable this (it exists for Builtin, as the runtime would likely segfault if someone unintentionally added a Method there). It is almost certainly not stable, but may be useful anyways to set inside Base, where overloading the wrong method may be common and lead to confusion (eg perhaps promote_type) or bugs (eg perhaps typejoin). However, it currently isn't general enough to prevent abusing getproperty to introduce unsoundness either, as it works at the MethodTable level, not on particular Methods
Motivation
Sometimes when designing an API, one wants to have a pair of public functions, where one is meant to be called by users, while the other is for users to overload (add methods to). An example in
Base
is thepromote_type
andpromote_rule
function pair. Thepromote_type
doc string is clear about users being forbidden from overloading this function:Still, many packages do overload
promote_type
:https://juliahub.com/ui/Search?q=promote_type&type=symbols&u=define&t=function
Proposed solutions
Some alternatives:
Nota bene
This issue arguably ties into the function/method sealing issue: #31222.
This issue arguably ties into the API specification issue: #49973.