Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30235

Re: Comparing some of the ways to create objects

From Scott Sauyet <scott@sauyet.com>
Newsgroups comp.lang.javascript
Subject Re: Comparing some of the ways to create objects
Date 2016-04-08 01:10 +0000
Organization A noiseless patient Spider
Message-ID <ne70et$2i4$1@dont-email.me> (permalink)
References <hbc2gbpvk5nk24b0qupps6cjqn8fm3ar5e@4ax.com> <ndspod$lhh$1@dont-email.me> <o435gb9fs37lmdqp7muur2nf9p9mn5nf7j@4ax.com> <ndvdg9$o4n$1@dont-email.me> <o9qcgbthcatgarbp46hs2nufsuouqmtn0k@4ax.com>

Show all headers | View raw


John Harris wrote:
> Scott Sauyet wrote:

>> I do not believe that concatenative prototyping is the only legitimate
>> form of prototypal inheritance.  Delegation-based prototyping is
>> reasonable, and has been part of prototypal languages since the very
>> beginning.
> 
> At last I've found out which meaning of delegate you are using. (There
> are 3 definitions in Wikipedia.) You mean using a function to do the
> work for you, using indirection to reach the function.

Well, no.

I simply mean that an object that is asked for a property that it doesn't 
have delegates the request to its prototype.  This is different from 
concatenative prototyping in which an object is created by cloning all of 
its prototype's properties and then remains disconnected from it.  The 
first prototypal language, Self, had both: concatenative by default, but 
with opt-in delegation mechanisms.  Most languages since choose one or 
the other.

>> There are certainly significant implementation similarities between
>> delegation-based prototypes and classes, but there are also significant
>> differences:
>>
>>    obj.prototype.method(...params);
>>
>> What's the equivalent of that in a class-based language?
> 
> In C++ you can access an inherited data or function member provided it
> hasn't been flagged as private. There is no problem about the 'this'
> value. 
>   struct A
>     {
>       int a(){return 3;}
>     };
>   struct F: public A { };
>   void f()
>     {
>       F f;        // f is 'obj'
>       f.A::a();   // A is 'prototype', a is 'method'
>     }

I'm not sure what you mean by "There is no problem about the 'this' 
value."  In an OOP context, and the whole point of my example, is that 
the code is running in the context of a particular object.  If a property 
of `this` is accessed or mutated, it will use the one stored on that 
prototype and not the object itself.  If the prototype is mutated, then 
any objects constructed from it which don't override the property now 
have the mutated value.

As far as I know this is entirely different behavior from any class-based 
languages that exist.


> [ ... ]
> Prototype objects really aren't the equivalent of classes or class
> definitions.

I certainly agree.  It seemed to me that you had been arguing the 
reverse.  I'm sorry if I misunderstood.

  -- Scott

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-03 16:09 +0100
  Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-04 04:15 +0000
    Re: Comparing some of the ways to create objects Stefan Weiss <krewecherl@gmail.com> - 2016-04-04 15:20 +0200
      Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-05 04:04 +0000
    Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-04 16:48 +0100
      Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-05 04:04 +0000
        Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-07 15:07 +0100
          Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-08 01:10 +0000
            Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-08 14:55 +0100
    Re: Comparing some of the ways to create objects Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-04 22:12 +0200
      Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-05 09:57 +0100
    Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-06 16:41 +0100
      Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-06 23:42 +0000
        Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-07 16:09 +0100
          Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-08 02:05 +0000
            Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-08 15:43 +0100
              Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-09 00:01 +0000
                Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-09 16:46 +0000
                Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-10 16:51 +0000
                Re: Comparing some of the ways to create objects Stanimir Stamenkov <s7an10@netscape.net> - 2016-05-08 17:27 +0300
                Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-10 11:31 +0100
                Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-10 11:52 +0100

csiph-web