On 2012-05-11 15:01, Roman D. Boiko wrote:

What about the following signature: Location locate(size_t index)?
Or even better:
alias size_t CodeUnitIndex;
Location locateFor(CodeUnitIndex position);

That is better although I would prefer to pass in a token (assuming that is where index is declared). Then it would be an implementation detail that "index" is used to get the location.

Another option would be to turn it around:

sturct/class Location
{
    Location find/locate (Token token);
}

The problem with placing it in Token is that Token should not know
anything about source as a whole.

I see. For convenience there could be properties defined that just forwards the call to some other function.

--
/Jacob Carlborg

Reply via email to