Function calls

Rainer Deyke rainerd at eldwood.com
Fri Jan 29 18:33:29 PST 2010


Michiel Helvensteijn wrote:
> Ah, my bad. I was guessing. Still, returning a handle from a property that
> can change the state of the originating object is.. iffy.

I disagree.

For example, I recently had to deal with tables.  Each table has rows
and columns.  Removing a row removes a cell from each column.  Removing
a column removes a cell from each row.  However, I wanted to deal with
both the set of rows and the set of columns as generic sequences.  My
solution was something like this:

struct Table {
  RowView rows();
  ColumnView columns();
};

I think 'rows' and 'columns' are perfect candidates for properties.
They are nouns, not verbs.  They could reasonably be implemented as
fields instead of functions.  They are not actions.  They are views into
the containing Table.  Aspects of the Table, if you will.  Properties.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list