Proposal to deprecate "retro.source"

monarch_dodra monarchdodra at gmail.com
Tue Nov 6 09:05:27 PST 2012


I just got snagged in a "funny" bug.

Using a generic template, I wanted a which shrank from the back. 
To do this, I made a call to "find(r.retro, stuff).source"

The idea being: Search from the back, and then extract the 
forward-iteration range from the result of find.

I got greeted with an "unknown property: source": WTF?

Turns out that in my function, "r" was already a retro range. In 
this condition, retro(r) un-retroed my range, which was all fine 
and well, but now it didn't have "source" anymore :/

The solution is actually quite easy, and already implemented: 
Just retro again!

The problem though is in the way the documentation "The original 
range can be accessed by using the source property" and "Applying 
retro twice to the same range yields the original range": Looks 
like we forgot to notice these two sentences are contradicting.

--------
To this end, I propose to deprecate "retro.source", and simply 
reword as:
*"Applying retro twice to the same range yields the original 
range"
*"The original range can be accessed by applying retro"

--------
I'd also like to not that this would avoid some *incredibly* 
unsafe code, that checks if R is of type retro by simply checking 
the *source* field... eg: to check if R1 is the retro of R2:
"is (typeof(r1.source) == typeof(r2))" //BAD! Could also be take, 
or who knows what!
which could be replace by
"is (typeof(r1.retro()) == typeof(r2))" //Good: Safe.

Thoughts?

(or if not deprecate, at least reword the documentation...)


More information about the Digitalmars-d mailing list