On Sat, 18 May 2013 16:35:29 +0200 "bearophile" <[email protected]> wrote:
> Some of you maybe remember the idea of the roles of variables: > > http://en.wikibooks.org/wiki/A-level_Computing/AQA/Problem_Solving,_Programming,_Data_Representation_and_Practical_Exercise/Fundamentals_of_Programming/The_Role_of_Variables > > http://www.cs.joensuu.fi/~saja/var_roles/role_list.html > > The idea is that in a program many variables have roles that can > be classified in few categories. Modern languages often offer > ways to express explicitly some of such roles, this makes the > code more readable and sometimes less bug prone. > > One of the roles that isn't built-in in D is the Follower, that > is variables that get their value by following another data > entity. They are "used to keep check of a previous value of a > variable, so that a new value can be compared." > > This is a basic implementation of a Follower in D (based on > std.typecons.Nullable), with an usage example on doubly linked > lists: > > > struct WithFollower(T, size_t N) { That's an interesting idea, I like it.
