foolang icon indicating copy to clipboard operation
foolang copied to clipboard

underscore methods as private

Open nikodemus opened this issue 3 years ago • 0 comments

Goals

  1. Documentation, validation of assumptions.
  2. Compiler is able to reason about which methods are dead.
  3. Classes which have system object cannot have them stolen vial private methods.
  4. Interactive / development mode escape hatch.

Idea

Reject sends of _-prefixed selectors to other than self, #sendTo: always rejects private selectors.

Thinking This Through

Is this enough for the compiler to reason about dead methods?

Yes. Since #_private cannot be used to send a message via #sendTo:, any _private methods that don't have an entry from the send-graph are dead.

(Reasoning about non-private methods requires also knowing about source references to symbols, and references to interning mechanism.)

Does this allow subverting the authority of the system object?

(Can someone steal authorizing objects from things that were supposed to encapsulate them.)

No.

How to provide an interactive escape hatch?

...not clear.

Possibly it would be a better idea to instead have _private methods interned in per-class symbol table?

nikodemus avatar Aug 22 '20 09:08 nikodemus