More D on reddit (DrBartoz comment)
mort
mortm at gmail.com
Mon Aug 4 13:30:03 PDT 2008
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.
More information about the Digitalmars-d
mailing list