From: Ry Nohryb on
On Apr 22, 3:17 am, "Richard Cornford" <Rich...(a)litotes.demon.co.uk>
wrote:
> (...)
> Thus any action(s) that get the ball rolling towards the current state
> happed in a window around 2003 - 2004. Considering that I posted the
> first (to the best of my knowledge) example of using an immediate call
> to an anonymous function expression intended to achieve some notion of
> 'private' (private static 'class' members in that case) in may 2003,
> (...) I think I have a very reasonable
> claim to be responsible for the (style and widespread) use of that
> construct in browser scripting today.
> (...)

http://groups.google.com/group/comp.lang.javascript/msg/a901528054294e4c

<quote>
On Oct 28 2003, 4:30 pm, "Richard Cornford"
<Rich...(a)litotes.demon.co.uk> wrote:
> (...)
> As Douglas Crockford appears to be responsible for inventing the
> technique for emulating private instance members in JavaScript (though I
> can't see that as "selling") it is probably not surprising that he has
> also published pages on alternative approaches to inheritance, some of
> which would address this problem.
>
> As the emulation of private instance members is achieved by forming a
> closure, in which the private members are stored, by assigning inner
> functions of the constructor to public members of the object instance,
> the technique results in each object instance being associated with a
> closure.
> (...)
</quote>

Now I'm lost. In 2003 you said it was him, but in 2010 you say it's
been you. How come ? What am I missing ?
--
Jorge.
From: Richard Cornford on
Ry Nohryb wrote:
> On Apr 22, 3:17 am, Richard Cornford wrote:
>> (...)
>> Thus any action(s) that get the ball rolling towards the
>> current state happed in a window around 2003 - 2004.
>> Considering that I posted the first (to the best of my knowledge)
>> example of using an immediate call to an anonymous function
>> expression intended to achieve some notion of 'private'
>> (private static 'class' members in that case) in may 2003,
>> (...) I think I have a very reasonable claim to be responsible
>> for the (style and widespread) use of that construct in browser
>> scripting today.
>> (...)
>
> http://groups.google.com/group/comp.lang.javascript/msg/a901528054294e4c
>
> <quote>
> On Oct 28 2003, 4:30 pm, "Richard Cornford" wrote:
>> (...)
>> As Douglas Crockford appears to be responsible for inventing the
>> technique for emulating private instance members in JavaScript
>> (though I can't see that as "selling") it is probably not
>> surprising that he has also published pages on alternative
>> approaches to inheritance, some of which would address this
>> problem.
>>
>> As the emulation of private instance members is achieved by
>> forming a closure, in which the private members are stored, by
>> assigning inner functions of the constructor to public members
>> of the object instance, the technique results in each object
>> instance being associated with a closure.
>> (...)
></quote>
>
> Now I'm lost. In 2003 you said it was him,

Said what was him?

> but in 2010 you say it's
> been you.

Say what has been me?

> How come ?

If the statements are true, why not?

> What am I missing ?

Apparently, and at minimum, the difference between the two subjects.

Richard.

From: Ry Nohryb on
On Jun 1, 8:41 am, "Richard Cornford" <Rich...(a)litotes.demon.co.uk>
wrote:
>
> > What am I missing ?
>
> Apparently, and at minimum, the difference between the two subjects.

Apparently, yes. What's the difference ?

function f () {}
var Clase= f();

vs.

var Clase = (function f () {})();

¿ That difference ?
--
Jorge.
From: Richard Cornford on
On Jun 1, 9:50 am, Ry Nohryb wrote:
> On Jun 1, 8:41 am, Richard Cornford wrote:
>>> What am I missing ?
>
>> Apparently, and at minimum, the difference between the two
>> subjects.
>
> Apparently, yes. What's the difference ?
>
> function f () {}
> var Clase= f();
>
> vs.
>
> var Clase = (function f () {})();
>
> ¿ That difference ?

Beyond one of them being the subject of this thread and the other not?

But what do either of those have to do with Douglas Crockford's
observation that (classical OO style) private instance members could
be emulated in javascript by forming a closure using a constructor? I
don't see any - new - operators or any indication of anything that
could be considered 'instances of a class', with or without 'private'
members.

Richard.
From: Ry Nohryb on
On Jun 1, 11:41 am, Richard Cornford <Rich...(a)litotes.demon.co.uk>
wrote:
> On Jun 1, 9:50 am, Ry Nohryb wrote:
> > On Jun 1, 8:41 am, Richard Cornford wrote:
> >>> What am I missing ?
>
> >> Apparently, and at minimum, the difference between the two
> >> subjects.
>
> > Apparently, yes. What's the difference ?
>
> > function f () {}
> > var Clase= f();
>
> > vs.
>
> > var Clase = (function f () {})();
>
> > ¿ That difference ?
>
> Beyond one of them being the subject of this thread and the other not?

Yes. Because if -as you said- "Douglas Crockford appears to be
responsible for inventing the technique for emulating private instance
members in JavaScript", and, -as you said- "I (you) posted the first
(to the best of my knowledge) example of using an immediate call to an
anonymous function expression intended to achieve some notion of
'private' (private static 'class' members in that case)", your "first
(to the best of my knowledge) example" was an application of his
invention, which means that his invention must have happened prior to
your example.

The point being, wasn't Crockford at that point clever enough already,
or, let's say, better, curious, inventive, creative enough to have
never done that ("that" being the use of an immediate call in order to
create the closure) himself ? Is this your understanding ? That he
never devised it until after you told/showed him ?

> But what do either of those have to do with Douglas Crockford's
> observation that (classical OO style) private instance members could
> be emulated in javascript by forming a closure using a constructor? I
> don't see any - new - operators or any indication of anything that
> could be considered 'instances of a class', with or without 'private'
> members.

But you can see the pattern where the constructor ("Clase") is the
returned value of a function call: the function call that is required
to create the closure to hold the private/privileged resources, which
is the matter we're talking about. I guessed that would suffice you,
or do I really need me to write a real constructor for you to get it ?
--
Jorge.