Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

naming this thing (function(){}())

4 views
Skip to first unread message

Stoyan

unread,
May 13, 2010, 4:53:20 PM5/13/10
to
Moving a discussion from twitter... Let's name this pattern :)

Some ideas include:
- self-executing function
- immediate function
- immediate invokation
- lexical block


Some thoughts:

@cowboy: IMO self-executing: function foo(){ foo(); }; Immediately
invoked: (function(){ ... })();

@abozhilov: I think that pattern need more abstract name. The
intention of pattern instead technical terms. and `(function (){})()`
is just one possibility for implementation these purposes.

@kangax: "immediate function" sounds a little awkward to me :) but
with "invocation" it's fine — "immediate invocation"

@DmitrySoshnikov no less than "self-executing". This term maybe fits
to recursive function, because exactly it executes itself. Immediate
invocation fits better for (correct naming) - an (anonymous) FE which
executes (by the engine, but not itself) right after its creating.
"Immediate function" seems apt, meaning "Immediate invocation of a FE
right after FE's creation".

Opinions?

Thomas 'PointedEars' Lahn

unread,
May 13, 2010, 5:12:43 PM5/13/10
to
Stoyan wrote:

> Moving a discussion from twitter... Let's name this pattern :)

No, thanks. This is _not_ a chat, we've been over this ad nauseam, and
naming the expression differently than what the Specification says (which is
understood by all involved because of that) serves no practical purpose. It
is a waste of time.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann

Garrett Smith

unread,
May 13, 2010, 5:28:51 PM5/13/10
to
Stoyan wrote:
> Moving a discussion from twitter... Let's name this pattern :)
>
> Some ideas include:
> - self-executing function

The function does not execute itself.

> - immediate function
The immediately invoked function itself is not immediate.

> - immediate invokation
Why only one k?
Describes the mechanics but not the application. Function that returns a
value is a bit different.

~function(){
Lib.addCallbac(anObj, "onevent", localFn);

function localFun() { /*...*/ }
}

> - lexical block
Less technically descriptive but seems more to the point of usage.

Immediately invoked function describes what it is correctly. It does not
explain how or why it is used, or if a value is explicitly returned, but
it is still my preference because it is technically correct.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/

RobG

unread,
May 13, 2010, 11:28:00 PM5/13/10
to
On May 14, 6:53 am, Stoyan <sst...@gmail.com> wrote:
> Moving a discussion from twitter... Let's name this pattern :)
>
> Some ideas include:
> - self-executing function
> - immediate function
> - immediate invokation
> - lexical block
>
> Some thoughts:
>
> @cowboy: IMO self-executing: function foo(){ foo(); }; Immediately
> invoked: (function(){ ... })();
>
> @abozhilov: I think that pattern need more abstract name. The
> intention of pattern instead technical terms. and `(function (){})()`
> is just one possibility for implementation these purposes.
[...]
> Opinions?

Before you can choose between various responses, you must first
establish the evaluation criteria. Here are some, in no particular
order.

The name:

* Should bear no resemblance whatever to what it actually is or does,
e.g. AJAX, Web 2.0, .NET, Cocoa, etc. Names like WebKit clearly fail
this criterion

* Should be catchy and annoy anyone who actually knows what it is
supposed to mean (see examples above). Even better if it's ambiguous
or misleading (extra points for both)

* Must have strange capitalisation and misspelling

* May have reference to some historical person who is vaguely related
to its invention, popularisation or folk lore, e.g. Yann-Erwan Perio
(YEP) or Richard Cornford

Some suggestions:

1. KwikExp

2. KwkFn

3. YepExp or YepFn

4. Yepify, Cornify (cf. currying[1])

and so on.

1. <URL: http://en.wikipedia.org/wiki/Currying >


--
Rob

David Mark

unread,
May 14, 2010, 2:04:47 AM5/14/10
to

Hell, why not HuckFinn? :)

>
> 3. YepExp or YepFn
>
> 4. Yepify, Cornify (cf. currying[1])

Some may say "Crockify", but then they'd be wrong. :)

>
> and so on.
>

What's wrong with one-off? ISTM that's what Richard has always called
it (and it fits).

Johannes Baagoe

unread,
May 14, 2010, 4:33:01 AM5/14/10
to
RobG :

> 4. Yepify, Cornify (cf. currying[1])

Cornford's Construct, like Duff's Device or the Muenchian Method. Or, in
the common case where a closure is created, Cornford's Closure.

--
Johannes

Garrett Smith

unread,
May 14, 2010, 6:01:54 PM5/14/10
to
RobG wrote:
> On May 14, 6:53 am, Stoyan <sst...@gmail.com> wrote:
>> Moving a discussion from twitter... Let's name this pattern :)
>>

[...]


> 4. Yepify, Cornify (cf. currying[1])
>

A function that has an explicit return has different context than one
that simply creates a lexical scope.

A pattern is a reusable solution a contextual problem.

A function that does not return a value creates a lexical scope returns
undefined. It can thus be thought of as a void function and so for that,
perhaps Cornvoid is a more suitable name than Cornify. But Cornvoid does
not roll off the tongue well. Maybe Cornhole?

nick

unread,
May 14, 2010, 7:28:34 PM5/14/10
to

I think we're definitely on the right track... now all it needs is a
few more syllables to jazz it up.

Perhaps (n.) Cornforfication and (v.) Cornforify?

Thomas 'PointedEars' Lahn

unread,
May 15, 2010, 9:06:27 AM5/15/10
to
Garrett Smith wrote:

Is there are proofread version of this available?


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300...@news.demon.co.uk> (2004)

0 new messages