Re: Terminology: “non-method function”

Axel Rauschmayer axel at rauschma.de
Wed Apr 11 05:58:38 PDT 2012


On Apr 11, 2012, at 12:37 , Alex Russell wrote:

> On Apr 11, 2012, at 1:02 AM, 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
> 
> What in the world would "defineMethod" do?

For `super` to work, a function needs a reference to the object that it is stored in. In the current object literal proposal [1], an object literal does it for you. If you don’t use an object literal, you need defineMethod.

> The confusing nature of the word "method" seems not to be cleared up by this. How about "bound" and "unbound" functions? Their iterability might bump them into "method" category if bound, but I think that's still just going to confuse non-JS folk.

I would make the following distinction:
#1 Intended use: non-method (callback? subroutine?) versus method.
#2 Implementation technique: bound function versus unbound function.

ES.next will shield you from the fact that you have to bind functions for them to work as expected as callbacks. I’m looking for a term that explains non-methods at #1 to people who are not familiar with JavaScript.


[1] http://wiki.ecmascript.org/doku.php?id=harmony:object_literals

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120411/fa23863e/attachment-0001.html>


More information about the es-discuss mailing list