Proposal for scoped const contracts

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 24 11:01:00 PDT 2008


"Steven Schveighoffer" wrote
> This idea has come from the discussion on the const debacle thread.
>
> It is basically an idea for scoped const.  The main goal is so that one 
> can specify that a function does not modify an argument without affecting 
> the constness of the input.
>
> The main problem to solve would be that I have a function with an argument 
> that returns a subset of the argument.  The easiest function to help 
> explain the problem is strchr.  Please please do NOT tell me that my 
> design is fundamentally unsound because you can return a range or pair, 
> and then slice the original arg based on that pair.  There are other 
> examples that cannot be solved this way, this is just the easiest to 
> explain with.  Everyone who uses C should know about strchr:
>
> char *strchr(char const *source, char const *pattern);

GAH!!! I meant this to be strstr.  Sorry everyone, please assume I meant 
strstr everywhere I wrote strchr.

-Steve 





More information about the Digitalmars-d mailing list