John G Harris wrote:
> On Sun, 23 Jul 2017 18:12:10 +0200, Thomas 'PointedEars' Lahn
> <
Point...@web.de> wrote:
>>Stefan Ram wrote:
>>>
bit-n...@hotmail.com writes:
>>>> Is "addEventListener" INSIDE it or something? How is that possible?
>>>
>>> Yes.
>>
>>N-O.
>>
>>> Objects can contain methods.
>>
>>N-O.
>
> We all know that software does not have insides and outsides. But
> software can implement conceptual things that do have insides and
> outsides. If anyone wants to think of an ECMAScript object as
> something that contains properties then they are not wrong. What would
> be wrong is criticising them for this view.
There is a difference between saying “an object contains a property” and
“an object contains a method”.
In ECMAScript 2016, § “4.2 ECMAScript Overview”:
,-<
http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-overview>
|
| […] a function is a callable object. A function that is associated with
^^^^^^^^^^^^^^^
| an object via a property is called a /method/.
|
| […]
| 4.3.30 property
|
| part of an object that associates a key (either a String value or a Symbol
| value) and a value
| […]
|
| 4.3.31 method
|
| function that is the value of a property
| […]
Section 4 “contains a non-normative overview of the ECMAScript Language”,
but there are no other explicit definitions for “method” in any Edition of
the Specification, so this is as best as it gets.
However, given the number of occurrences where it is being said that an
object “_has_ a property”, including names such as “hasOwnProperty”,
I (among others) prefer and recommend to use *that* wording instead.
[The same goes for “references”: the fact that the modification of the
properties of an object #1 can simultaneously affect the properties of
two distinct other objects #2 and #3 is easier to understand if one
does not assume that object #1 is the value of both the property of
objects #2 and #3, and somehow object #1 is contained in both objects
#2 and #3, but is being referred to by the value of their properties
(reference value). Which also comes closer to what is mostly being
implemented (a property name maps to a pointer value referring a memory
area where object data is stored).]
>> Objects *in ECMAScript implementations* can have *properties* whose
>> value is a reference to a callable object;
>
> ... whose value is an object with a [[Call]] internal method; ...
>
> Please use the terminology specified in ECMA 262.
You do not know “ECMA 262” as well as you think you do (you do not even know
that it is properly written _ECMA-262_, and then the term is still imprecise
due to the several Editions).
The term “callable object” is not my invention. See above, and e.g.
ECMAScript 2016, § “6.1.7.2 Object Internal Methods and Internal Slots”:
,-<
http://www.ecma-international.org/ecma-262/7.0/#table-6>
|
| Table 6: Additional Essential Internal Methods of Function Objects
|
| Internal Method Signature Description
| ------------------------------------------------------------------------
| [[Call]] (any, a List of any) → any Executes code associated
| with this object. Invoked
| via a function call
| expression. The arguments
| to the internal method are
| a *this* value and a list
| containing the arguments
| passed to the function by
| a call expression. Objects
^^^^^^^^^^^^^^^^^^^^^^^^^^
| that implement this
^^^^^^^^^^^^^^^^^^^
| internal method are
^^^^^^^^^^^^^^^^^^^
| /callable/.
^^^^^^^^^^^
Moreover, you have failed to realize that those internal methods and slots
are purely specification mechanisms:
| 6.1.7.2 Object Internal Methods and Internal Slots
|
| The actual semantics of objects, in ECMAScript, are specified via
| algorithms called internal methods. Each object in an ECMAScript engine is
| associated with a set of internal methods that defines its runtime
| behaviour. These internal methods are not part of the ECMAScript language.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| They are defined by this specification purely for expository purposes.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| However, each object within an implementation of ECMAScript must behave as
| specified by the internal methods associated with it. The exact manner in
| which this is accomplished is determined by the implementation.
(*That* section, “6 ECMAScript Data Types and Values”, *is* normative.)