More D on reddit (DrBartoz comment)
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Mon Aug 11 08:32:34 PDT 2008
mort wrote:
> Bruno Medeiros Wrote:
>
>> DrBartoz commented: [...]
>>
>> Why would the whole source code the library be needed for that? Isn't it
>> necessary only for the library API to be well-specified in terms of it's
>> const semantics?
>
> You could setup 'const inference' to stop at package/library boundaries, but it wouldn't be as powerful. Consider the function 'Object id(Object x) { return x; }'. This function is const-polymorphic. There's no way to explicitly tag it as const without reducing its applicability since you might want to pass in const parameters in some places and mutate the result in others. Also, I think you'd have to tweak the syntax to avoid confusion - you might not want the default (when specifiers are absent) to be 'not-const' at package level and 'inferred-const' elsewhere.
>
>
But you can't specify a "const-polymorphic" function with the current
const system either. You (the library writer) would have to define two
functions, so const-inference wouldn't limit you in any way.
--
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list