Patricia Shanahan <> writes:
>1. A method whose contract specifies setting an instance variable.
>2. A method whose contract specifies setting a logical property of the
>object.
>To me, it seems wasteful to use an nice, short, simple term for
>something that should *never* exist, when it could equally well be used
>for something that is actually useful, so I prefer the second definition.
I now try to look it up in the »Wikipedia.« The first relevant content
I find with my search approach is:
»Unlike the "getter" and "setter" methods of other
languages like C++ or Java, accessor methods in Ruby are
created with a single line of code via metaprogramming.«
http://en.wikipedia.org/wiki/Ruby_(programming_language)
This seems to imply the meaning »1.«.
The next hit:
»Integer extend [
asClosure [
| value |
value := self.
^{ [

| value := x ]. [ value ] }
]
]
blocks := 10 asClosure.
setter := blocks first.
getter := blocks second.
getter value "=> 10"
setter value: 21 "=> 21"
getter value "=> 21"«
http://en.wikipedia.org/wiki/GNU_Smalltalk
This also seems to imply an access to the internal
variable »value« of the closure. Disclaimer: I did
not learn Smalltalk yet.
Found Last, but not appreciated least, the main article:
»The mutator method, sometimes called a "setter", is
most often used in object-oriented programming, in
keeping with the principle of encapsulation. According
to this principle, member variables of a class are made
private to hide and protect them from other code, and
can only be modified by a public member function (the
mutator method), which takes the desired new value as a
parameter, optionally validates it, and modifies the
private member variable.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Often a "setter" is accompanied by a "getter" (also
known as an accessor), which returns the value of the
private member variable.«
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
http://en.wikipedia.org/wiki/Mutator_method
Reads like more close to »1.« to me.
(The foregoing quotations from the »Wikipedia« that I have
provided in this Usenet post were not written into the
»Wikipedia« by me. I never edited any of the »Wikipedia«
articles quoted above, I just underlined two lines in this
Usenet post.)