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

S

Stoyan

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?
 
T

Thomas 'PointedEars' Lahn

Stoyan said:
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
 
G

Garrett Smith

Stoyan said:
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.
 
R

RobG

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 >
 
D

David Mark

RobG said:
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

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).
 
G

Garrett Smith

RobG said:
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?
 
N

nick

RobG said:
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?

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?
 
T

Thomas 'PointedEars' Lahn

Garrett said:
RobG said:
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?

Is there are proofread version of this available?


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top