[Issue 2635] $ for user-defined slices should forward to value.length, not global __dollar. Also injected "length" must go.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 29 18:28:49 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2635





------- Comment #1 from schveiguy at yahoo.com  2009-01-29 20:28 -------
I think expanding to length is not always correct, although I do agree that it
can be solved with the proposed method.

Length is not always the name of the term you would pass to a slice.

Example: sorted dictionary (Red-black tree based for instance).  A slice of
this container would use two key types as slice indexes.  So you would have to
define a property length that returns a key, which is super unintuitive for
people who are trying to use the length property outside a slicing operation
(imagine if the key type is string, your length has to return a string).

I think the opDollar would suit this rather well, but maybe call it opSliceEnd,
or something like that (to follow the spirit of current operator naming
scheme).


-- 



More information about the Digitalmars-d-bugs mailing list