Ticket #237 (closed defect: wontfix)

Opened 1 year ago

Last modified 1 year ago

Shared prototype as an in-the-language facility

Reported by: lth Assigned to: anonymous
Type: defect Priority: major
Milestone: Component: Proposals
Version: 4 Keywords:
Cc: brendan,graydon,jeffdyer

Description

Thought experiment:

    class C prototype Number {
       // shares the prototype of Number
       // prototype properties are illegal in this class body
    }

Three benefits:

  • less magic
  • user code gets it too
  • static checking that the class does not add proto props when it shouldn't

Costs:

  • more language to spec for a special case that is really for ES3 code, mainly (we think (for the moment))

Neither "extends" nor "implements" are precluded, but "prototype" overrides "extends" as far as determining the prototype goes.

Attachments

Change History

Changed 1 year ago by lth

  • status changed from new to closed
  • resolution set to invalid

Withdrawn -- no comments, proposal period closed.

Changed 1 year ago by lth

  • status changed from closed to reopened
  • resolution deleted

I'm reopening this because I suspect it has greater utility than we might have thought.

On es4-discuss I just used this kind of a class as an example:

class UniqueArray.<T> {
   meta function get ...
   meta function set ...
   ...
}

The whole point here is to allow the generic array methods to be used. HOWEVER, those methods are on the Array prototype and would need to be explicitly transferred to the prototype of UniqueArray?.

IMO this would be natural:

class UniqueArray.<T> prototype Array {
   ...
}

On the other hand, subclassing Array may also be possible.

Changed 1 year ago by lth

  • status changed from reopened to closed
  • resolution set to wontfix

There are some weaknesses in the current Array design with how generics are handled, maybe they should be toplevel or something. Anyhow, we close this again.

Note: See TracTickets for help on using tickets.