const Propagation
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Mon Dec 29 12:14:02 PST 2014
On Mon, 29 Dec 2014 20:07:08 +0000
evenex via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
> > Is that really cool? I mean, is wise to have the compiler treat
> > templates and non-templates differently? C++ has tons of such
> > inconsistencies which is the main reason I don't really like
> > C++...
>
> Well, it is reasonable in light of the fact that templates
> require the source to be available (which guarantees the compiler
> can analyze it) while regular functions might not be (e.g. if
> they are in a precompiled library). In this sense, making a
> function into a zero-param template is equivalent to telling the
> compiler that it is free to analyze the source.
> That being said, I sympathize with the sentiment - it would be
> more consistent if all functions whose source was available could
> be auto-annotated. I'm not sure what the technical impediments to
> this might be, though. Still, adding an extra () to the function
> signature is not too inconvenient, and carries some additional
> benefits.
> I find annotations and qualifiers to be part of the "ugly" side
> of D, and try to avoid using them (took me awhile to figure out
> that C++ style const-correctness doesn't work in D, due to
> transitivity) but I'm afraid don't know enough about compilers to
> make a more informed judgement than "that's just how it is."
> Maybe someone with more experience in this area could weigh in?
you get it right. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141229/0c979e5a/attachment.sig>
More information about the Digitalmars-d
mailing list