Is there a word for the API pattern where a method may get or set, depending on whether it is called with an argument or none?

This style is often used in JavaScript:

obj.prop();                // Returns value
obj.prop(new_value);       // Sets new value

A variation for dictionary-like properties takes one or two arguments respectively:

obj.dict(key);             // Returns value for key
obj.dict(key, new_value);  // Sets new value for key

Again, does this style have a name?

EDIT: The word proxy doesn't seem half bad to me. Any devastating arguments against calling these kind of functions proxies?

closed as primarily opinion-based by amon, Jules, Bart van Ingen Schenau, gnat, BЈовић Oct 8 '15 at 12:57

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    I call it an accessor method, but in the end there's no right answer. I'm therefore voting to close this question as “primarily opinion-based”. – amon Oct 8 '15 at 7:26
  • 4
    That isn't one method, it's two different methods, they're just related by overloading. The generic term is accessor, but each of these methods is still a getter or a setter, not just an accessor. – Kilian Foth Oct 8 '15 at 7:26
  • Accessor-mutator and getter-setter – these are word pairs that are used in less dynamic languages. I'm looking for a single word. I guess "accessor" is the more generic one... – dalgard Oct 8 '15 at 7:27
  • I don't think it's viable using the term "overloading" in the context of JavaScript. – dalgard Oct 8 '15 at 7:28
  • 1
    @dalgard Proxy is used for a different concept (see Proxy pattern on wikipedia), so that wouldd be very confusing. Accessor is decent choice. – CodesInChaos Oct 8 '15 at 7:55

Browse other questions tagged or ask your own question.