New Issue: Owned/Shared module - are we okay with clear being taken out of the user's namespace control?

20336, "lydia-duncan", "Owned/Shared module - are we okay with clear being taken out of the user's namespace control?", "2022-07-29T22:31:54Z"

I discovered this while implementing DistributedMap. maps today have a clear method and I was toying with making distributedMap a class so that there could potentially be an inheritance relationship, enabling a function to accept either a map or a distributedMap. But unfortunately, if I make it a class any attempts to call the map/distributedMap clear method will instead resolve to the owned/shared clear method, resulting in this error message if I try to clear it and then do something else with the instance:

test.chpl:13: error: Cannot transfer ownership from a non-nilable outer variable
test.chpl:14: error: Illegal use of dead value
test.chpl:13: note: 'm' is dead due to ownership transfer here
test.chpl:14: error: mention of non-nilable variable after ownership is transferred out of it

While there's probably something else that can be done to enable a function to accept both maps and distributedMaps, this begs the question: is it okay that owned and shared are using a name as common as clear? It surprised me and my first instinct when I got the message was to look if the clear method I wrote was doing something weird with its this argument - I think it will be difficult to debug for a user that happens to write their own method named clear. A quick example - if the user is writing a graphical display type, they might lean towards naming a method that cleans the display clear. And of course there's other collection types.