Summary: $ for user-defined slices should forward to
                    value.length, not global __dollar. Also injected
                    "length" must go.
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

Good uses of $ came forth in conjunction with infinite ranges and
sentinel-terminated ranges (e.g. singly-linked lists). Those don't have a
length defined or easily computed, so slicing with range[n .. $] is possible
whereas range[n .. m] is not possible. 

To effect that, no extra opDollar etc. is needed; we can work with the "length"
attribute of the value being indexed/sliced.

a) In slice expressions and index expressions with ONE argument, $ should
expand to value.length, where value is the object being indexed/sliced (if an
unnamed temporary, the value is of course only evaluated once).

b) In index expressions with multiple arguments, $ expand to value.length(i),
where i is the zero-based argument position.

This is exactly enough what's needed to make it all work. Infinite
ranges may define a symbolic infinite length and overload slicing on it.


Reply via email to