From: John G Harris on
On Sun, 3 Jan 2010 at 08:38:18, in comp.lang.javascript, Dmitry A.
Soshnikov wrote:
>On 3 0
<snip>
>> terrible idea
>> terrible
>> terrible idea
>
>Please, don't use demagogy, propaganda, and
<snip>

Please don't give such misleading quotes. They are a form of demagogy
and propaganda.


You could have quoted like this :

>> In a Web page, it's generally a terrible idea

<your complaint about 'terrible'>

>>as scripts typically
>> have to co-exist with others.

<your agreement about 'co-exist'>

John
--
John Harris
From: Dmitry A. Soshnikov on
On 3 янв, 20:51, John G Harris <j...(a)nospam.demon.co.uk> wrote:
> On Sun, 3 Jan 2010 at 08:38:18, in comp.lang.javascript, Dmitry A.Soshnikov wrote:
> >On 3 0
>   <snip>
> >> terrible idea
> >> terrible
> >> terrible idea
>
> >Please, don't use demagogy, propaganda, and
>
>   <snip>
>
> Please don't give such misleading quotes. They are a form of demagogy
> and propaganda.
>

Please, pay attention that I used it specially (as a kind of irony) to
show, how it looks. For what reason, I should give in on provocation
and accept such rules when one person statements his humble opinion
with sure tone "That's wrong. That's terrible." (this person tries to
take the main role and to take the dialog in his hands) and the other
one should prove why it's not so (this person is kind of that
justifies). It's direct demagogy which I see and don't wanna accept.
That's it. Objections?

> You could have quoted like this :
>
> >> In a Web page, it's generally a terrible idea
>
>   <your complaint about 'terrible'>
>

I know that, thanks.

> >>as scripts typically
> >> have to co-exist with others.
>
>   <your agreement about 'co-exist'>
>

I also know that, thanks.

/ds
From: Jorge on
On Jan 3, 6:51 pm, John G Harris <j...(a)nospam.demon.co.uk> wrote:
> (...)
> >> as scripts typically
> >> have to co-exist with others.
>
> <your agreement about 'co-exist'>

"agreement" ?

The typicality of that hypothetical coexistence is very debatable.
And, in any case, "others" is !== "unknown scripts". Do you allow
"unknown" code to run in your page ? Does any of these -hypothetical-
cohabitant scripts break anything ? And if they do, why ? Don't their
authors know about .hasOwnProperty() existence and purpose ? Is that
reason enough to ditch .prototype inheritance altogether ? The answer,
in general, is NOT yes. The answer, in general, is of course NOT.
--
Jorge.
From: David Mark on
On Jan 3, 1:50 pm, Jorge <jo...(a)jorgechamorro.com> wrote:
> On Jan 3, 6:51 pm, John G Harris <j...(a)nospam.demon.co.uk> wrote:
>
> > (...)
> > >> as scripts typically
> > >> have to co-exist with others.
>
> > <your agreement about 'co-exist'>
>
> "agreement" ?
>
> The typicality of that hypothetical coexistence is very debatable.

That's ludicrous. How many Web pages use a single script from a
single author (well, I know of a few at least). :)

> And, in any case, "others" is !== "unknown scripts". Do you allow
> "unknown" code to run in your page ?

Me? Not typically, no. Am I typical?

> Does any of these -hypothetical-
> cohabitant scripts break anything ?

You are babbling.

> And if they do, why ? Don't their
> authors know about .hasOwnProperty() existence and purpose ?

You truly are a student of Crockford. For about the millionth time,
that method doesn't work in "ancient" browsers like Safari 2. I see
it used without proper feature detection and wonder if the authors
realize their scripts will suddenly halt at that spot. Does that seem
a sound degradation strategy to you?

And of all the miserable JS libraries out there, how many actually
filter for-in loops in any form?

> Is that
> reason enough to ditch .prototype inheritance altogether ?

Does it seem to you that I've "ditched" ".prototype inheritance".
Look again.

> The answer,
> in general, is NOT yes.
> The answer, in general, is of course NOT.

Lucid as always. :)
From: JR on
On Jan 3, 3:40 am, Ryan Chan <ryanchan...(a)gmail.com> wrote:
> Have read Douglas Crockfore's JavaScript The Good Parts, it recommend
> Augmenting Types, e.g.
>
> Function.prototype.method = function(name, func) {
>     this.prototype[name] = func;
>     return this;
>
> };

I've read the book too, but in my version (2008 in Portuguese) that
function is slightly different, with one very important feature test:

Function.prototype.method = function (name, func) {
if (!this.prototype[name]) {
this.prototype[name] = func;
// I didn't see this return this mentioned above.
}
};

And there is a precautionary note about augmenting types, specially
when the page utilizes different libraries / codes.
I also have not read Douglas recommending this type of thing, but
saying that it was possible to do so, arguing that it could make
improvements in the expressiveness of JavaScript.

However, I must admit that that 'part' of the book is confusing and
can mislead readers about the matter (augmenting types); in other
words, a reader might unwittingly adopt the book's example as a good
practice, what would be a temerity.

> String.method('trim', function() {
>     return this.replace(/^\s+|\s+$/g, '');
>
> });
>
> Is this a good thing in your opinion?

No, it isn't, even in case you know exactly what you're doing.

--
JR