Steven Schveighoffer:

It all depends on how you model the data. If the data is contained/owned by a single instance, then you can store the length inside that instance. If it's not owned (i.e. sublists are also valid SLists) then you cannot do that.

Let me add something to your answer. With Dependent Types
(http://en.wikipedia.org/wiki/Dependent_types ) you are sometimes
able to use the list length, encoded in the types, despite at
run-time the lengths aren't stored in the run-time data structure
:-)

This is not always possible, and it generally requires a type
system more powerful than the D type system if you also want it
to be sufficiently handy to use.

Bye,
bearophile

Reply via email to