Ticket #203 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Builtins: Should the new types have a static "length" property?

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

Description

spec/library/Vector.html and others: should the new types (int, uint, decimal, double, string, boolean, Vector, Map, ControlInspector?, EncodingError? and whatever others might come along) have a "length" property encoding the number of arguments the constructor expects?

For some (the ones that model the primitive types of ES3) the answer is presumably an easy "yes", but what about the others?

Attachments

Change History

Changed 1 year ago by lth

Also Name, Namespace

Changed 1 year ago by brendan

I suggested in an old version of the bug_fixes proposal that we use arity as the new name for this property, and deprecate length somehow -- for functions and classes. One way to do it is to preserve length only for the classes defined by ES3 and for function objects, but not keep imposing length on new classes.

This is weak, it might just add to the clutter, but it could wean users off of length (if indeed some users actually do use it -- I recall seeing uses, but I don't remember whether on functions, class constructors [which are function objects in ES3], or both -- have to assume both).

/be

Changed 1 year ago by lth

Given that you can extract the constructor with the meta-objects system and query the constructor for its argument list length (though cumbersomely) I don't know that we need more features for that (ie, "arity"). I think we should stick with "length", or keep "length" for the legacy classes but not implement it in the new ones.

I don't mind the name at all, it's wrong but it's there and there's no ambiguity about it. The properties we have won't go away so it's tainted for all eternity. Etc.

I probably favor just dropping it in the new classes, but I don't mind much if we add it even to those.

(There's a related bug, I forget the ticket, which asks if the language shouldn't just always add a static "length" property to the class to reveal the desired number of parameters to the constructor.)

Changed 1 year ago by brendan

Yeah, I relented in the past and here do again: no gain in clutter. But if we have length for some classes and all functions, but not for other classes, that will bite someone (perhaps even us, in the future). So I favor keeping it universally defined. (I write "it" because it still pains me to write "length", but I'll get over it.)

/be

Changed 1 year ago by lth

The related bug is #84.

I will add "length" to all the builtins, and we will resolve later (not too much later...) whether that property is auto-created on all classes or manually created on just the builtins.

Changed 1 year ago by lth

Fixed in builtins and spec. I did not add a "length" to Namespace because it does not have a public constructor. We can/should discuss this, I'll open a new ticket.

Changed 1 year ago by lth

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.