Re: Terminology: “non-method function”
axel at rauschma.de
Tue Apr 10 17:43:50 PDT 2012
On Apr 11, 2012, at 2:02 , Allen Wirfs-Brock wrote:
> On Apr 10, 2012, at 4:01 PM, Axel Rauschmayer wrote:
>> What is a good term for functions that don’t have/use dynamic `this`? “Non-method function” defines them by what they aren’t, I would like a positive definition. I’ve considered the term “pure function”, but the adjective “pure” is already heavily overloaded, especially in functional programming.
>> Any ideas?
> How about:
> procedure - call "callable" object
> method - a procedure that has a dynamic this (or super) dependency
> function - a procedure that does not have a dynamic this dependency
> detached method - a method that has not been associated with an object via Object.defineMethod
callableObject instanceof Function
Thus, how about the following:
- Function: a callable object
- Method: A function that has a dynamic this (or super) dependency.
- Callback: A function that does not have a dynamic this dependency.
Not ideal (and in some ways, not as precise), but possibly less confusing.
Interestingly, that would make Math.* (etc.) callbacks, not methods. That works, because Math is just a namespace.
> FunctionDeclarations and FunctionExpressions may be used to define either methods or functions.
> Arrow Function expression only define functions
The following is the messy one:
> Concise method definitions in object literals and class definitions may define either methods or functions
Clearly, one’s‚ intention is to define a method. But we may have to live with that, because it’s probably better to categorize callable objects according to some trait of theirs and not according to how they are used at the moment. (I’m not 100% sure, though.) Definitions using the latter approach would be “a function that is the value of a property” or “a function-valued property”.
Dr. Axel Rauschmayer
axel at rauschma.de
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss