Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26522
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Can somebody explain this to me |
| Date | Fri, 09 Jan 2015 22:11:48 +0100 |
| Organization | PointedEars Software (PES) |
| Lines | 157 |
| Message-ID | <2325067.SlJVB63eap@PointedEars.de> (permalink) |
| References | <m8f7s7$lcv$1@dont-email.me> <1590597.KOVAYohEvS@PointedEars.de> <qj1oaahmnp3r6j45b27sm5ujsfhqu4igv6@4ax.com> <1761561.NWXpXnK3hu@PointedEars.de> <4ikqaa9iqmr7jd2qtiqhbsv47frcvjq12t@4ax.com> <1484912.4aj6z3n5JQ@PointedEars.de> <7dd0badq67nid10hcrgs0l2f5r7td12jbo@4ax.com> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1420837932 1555 eJwVwoERwEAEBMCW4nGinCP0X8JPZtcVgg6Dw3x/J2vr2Tyh0m/k+RQcZyjZShXOYmwdGV4XIooRaw== (9 Jan 2015 21:12:12 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Fri, 9 Jan 2015 21:12:12 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| X-User-ID | eJwNyskNACAMA7CVUnrBOFCa/UeApyW7hkSlhYc5nWmHA7uWc6LDM0Ecg+RSK+oY1/7fKLC/Zq622wfiKnLzAT6eFMY= |
| Cancel-Lock | sha1:YfDXsPX5N3xgMJoDEkS2f/d009E= |
| X-NNTP-Posting-Host | eJwFwQkRwEAIBDBLx7eAnC0M/iU0CYNg0hHwuLi3FGcNJJ6+Lit0wpuJtgvmSdWn3FViTH7/sBBJ |
| Xref | csiph.com comp.lang.javascript:26522 |
Show key headers only | View raw
John Harris wrote:
> Thomas 'PointedEars' Lahn wrote:
>> John Harris wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> John Harris wrote:
> <snip>
>>>>> No; here is the class's constructor function.
>>>> Utter nonsense.
>>> It *is* a constructor function.
>> But _not_ a classs.
>
> "Utter" implies all of it is wrong.
Adding “class’s” makes it all wrong.
That said, in this context “utter” does not carry that meaning in my book.
I understand it to be the kind of nonsense that if the author had put a
little more thought into it, they would have realized by themselves that it
is nonsense (of the kind that is *not* humorous) and would have refrained
from making the statement. I do not think I am alone there.
>> And one might find out then that the constructed objects have not much if
>> anything in common even before the caller starts to augment them.
>> Therefore it is just a constructor (function), not a "classs constructor
>> (function)",
>> and certainly it is _not_ a "class". Generally speaking, a class of
>> objects need to have something, if not most of their properties, in
>> common, hence the term in computer science too.
>
> It's a funny constructor that doesn't create equivalent objects.
Quite normal in ECMAScript, though. Because a constructor in ECMAScript is
_not_ (like) a class declaration/definition, some objects thus created can
have some properties (that includes methods) that others have not:
function C (a)
{
if (a)
{
this.a = a;
}
}
There is a well known precedent, although a host object: ActiveXObject.
Depending on the arguments of the constructor call, an entirely different
object will be constructed.
> (Same property names, same prototype chain).
Not necessarily. As for the latter, a constructor can return a value.
If that value is of the Object type, the referred object is returned instead
of the “this” value. AISB, I am using this to return a Proxy instance if
possible.
In fact, because a constructor defined by function declaration can virtually
replace itself, the constructed objects need not have to have the same
constructor even if the constructor calls are byte-by-byte-equal source
code.
Bottom line: A constructor in ECMAScript is not like a constructor of a
class; it is more like a(n object) factory. In fact, in more recent
implementations it takes only one line, three at most, so that a constructor
can be called as a function, like a factory, and still work as if it was
called as a constructor:
function C (a, b)
{
if (!(this instanceof C)) { return new C(a, b); }
/* … */
}
I have posted this here before.
[Because this is so common a pattern, I have created, with a little help
from this newsgroup, Function.prototype.construct() and .construct2() with
which you can call any Function instance as constructor without using “new”
explicitly. This allows the effective argument list to be of arbitrary
length, passed as an array-like object:
function C (a, b)
{
if (!(this instanceof C)) { return C.construct(arguments); }
/* … */
}
]
> In your words, the created objects have something in common.
Not necessarily.
> If the program goes on to make arbitrary changes to the properties
> held then obviously the program is not taking advantage of their
> initial equivalence, and so not treating them as members of a class.
I have already pointed out that the caller need not modify the constructed
objects for differences between the instances.
>>> It would be advantageous if that were written down in the
>>> program's documentation before coding, [
]
>>
>>It would be advantageous if you got yourself a minimum clue before you
>>post again.
>
> There are dozens, if not hundreds, of books on how to organise an
> enterprise-scale software project. You have now declared all these
> books to be rubbish.
No, I declared what you wrote on ECMAScript “rubbish”, in your wording.
> <snip>
>>Red herring. Your statement is somewhat interesting (though off-topic),
>>but entirely irrelevant to the question at hand, which is Should one
>>refer to a constructor as a "class" (as you prefer to)?.
>
> I *never* refer to a constructor as a "class".
Then you should not have objected in the first place because that was the
question at hand.
> A class is a class of objects, not their constructor function(s), nor
> their definition (explicit or implicit).
But I followed up on an OP that claimed something else. You objected to
what I wrote there.
>>I think that sufficient
>>arguments, authoritative evidence indeed, has been presented by more than
>>one person here to conclude that one should not.
>
>>So everyones life not least that of newcomers seeking clarity here
>>would be easier if you *please* stop doing that.
>
> From the earliest JavaScript onward the language(s) have had all the
> facilities needed to implement classes.
Doubtful; you will have to prove that. And which kind of classes? C++’s?
Java’s? Something else’s?
I can certainly agree that it is possible to use JavaScript, all major
ECMAScript implementations really, to implement some features of class-based
inheritance; I am doing that myself.
But what matters is: It/they did not *have* classes until now (if we ignore
the ECMAScript Edition 4 draft and its implementations). The authoritative
documentation of the respective programming language does not feature that
term; in fact, it explicitly says that there are no classes in either
language, and rightly so. To claim otherwise is misleading. It is you who
made the claim, and *that* was to which I, among others, objected.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Can somebody explain this to me "Tony Johansson" <johansson.andersson@telia.com> - 2015-01-06 00:48 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-06 01:40 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-06 16:01 +0000
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-06 17:26 +0100
Re: Can somebody explain this to me Joao Rodrigues <groups_jr-1@yahoo.com> - 2015-01-07 00:45 -0200
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-07 04:35 +0100
Re: Can somebody explain this to me Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-01-07 16:15 -0200
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-07 21:20 +0100
Re: Can somebody explain this to me "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-08 00:00 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-08 00:09 +0100
Re: Can somebody explain this to me "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-08 10:53 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-08 16:17 +0100
Re: Can somebody explain this to me "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-08 17:04 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-08 19:02 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-07 15:37 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-07 17:01 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-08 10:43 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-08 13:16 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-08 16:43 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-09 20:16 +0000
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-09 22:11 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-10 16:58 +0000
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-11 12:41 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-12 15:46 +0000
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 18:01 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-13 10:38 +0000
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-14 16:06 +0000
Re: Can somebody explain this to me Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-21 13:00 -0800
Re: Can somebody explain this to me Joao Rodrigues <groups_jr-1@yahoo.com> - 2015-01-21 20:53 -0200
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-22 11:43 +0000
Re: Can somebody explain this to me Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-01-22 10:20 -0200
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-23 19:42 +0000
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-28 18:14 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-22 11:39 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-22 13:27 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-23 14:36 +0000
Re: Can somebody explain this to me Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-23 08:51 -0800
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-23 23:17 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-24 16:42 +0000
Re: Can somebody explain this to me Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-24 15:35 -0800
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-25 11:08 +0000
Re: Can somebody explain this to me "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-26 08:33 -0800
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-27 14:10 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-28 15:50 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-28 18:26 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-29 10:29 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-31 00:37 +0100
Re: Can somebody explain this to me "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-28 13:30 -0800
Re: Can somebody explain this to me "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-28 22:40 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-29 10:32 +0000
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-29 10:23 +0000
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-29 11:04 +0000
Re: Can somebody explain this to me "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-26 08:21 -0800
Re: Can somebody explain this to me Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-26 11:10 -0800
Re: Can somebody explain this to me Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-22 06:36 -0800
Re: Can somebody explain this to me Tim Streater <timstreater@greenbee.net> - 2015-01-06 17:34 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-06 19:03 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-07 15:07 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-07 16:41 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-07 17:22 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-08 10:36 +0000
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-08 13:36 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-08 17:54 +0100
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-08 19:48 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-08 22:09 +0100
Re: Can somebody explain this to me Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-01-08 18:22 -0200
Re: Can somebody explain this to me "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-08 22:13 +0100
Re: Can somebody explain this to me Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-08 22:25 +0100
Re: Can somebody explain this to me John Harris <niam@jghnorth.org.uk.invalid> - 2015-01-08 10:25 +0000
Re: Can somebody explain this to me "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-08 11:33 +0100
csiph-web