Bug 16370 – outdated spec: templated functions allowed in interfaces and functions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-08-10T16:14:29Z
Last change time
2019-12-21T03:56:22Z
Keywords
pull, spec
Assigned to
No Owner
Creator
Lodovico Giaretta
See also
https://issues.dlang.org/show_bug.cgi?id=16371

Comments

Comment #0 by lodovico — 2016-08-10T16:14:29Z
The last line of this page [1] says that interfaces cannot contain templated functions (and suggest the compiler should raise an error). But DMD allows templated functions in interfaces, making them implicitly final. From a thread [2] it looks like this was a conscious addition, so the spec shall be updated. [1] https://dlang.org/spec/template.html#limitations [2] http://forum.dlang.org/post/[email protected]
Comment #1 by schveiguy — 2016-08-10T16:36:47Z
Comment #2 by schveiguy — 2016-08-10T16:39:10Z
Whoops! I misread the docs. I'll update the PR and restore the original description. I still like my PR change, as to be clearer.
Comment #3 by schveiguy — 2016-08-10T16:43:57Z
The limitation that templates can't be inside functions also is no longer true!
Comment #4 by issues.dlang — 2016-08-11T06:26:46Z
(In reply to Steven Schveighoffer from comment #3) > The limitation that templates can't be inside functions also is no longer > true! IIRC, it at least _was_ the case that you could put a template in a function but that you could only instantiated it once (which was _very_ annoying for unit testing). Has that changed? Walter didn't agree that it was a problem and didn't want to change it. I _thought_ that I'd opened a bug on it, but I can't find it now (be it closed or open).
Comment #5 by schveiguy — 2016-08-11T12:39:32Z
Tested with this, and it compiled: void main() { int foo(T)(T t) { return 1; } foo(0); foo("hi"); }
Comment #6 by issues.dlang — 2016-08-11T13:13:57Z
Well, that's a definite improvement then. It means that I can move a bunch of unit testing functions into unittest blocks where they belong.
Comment #7 by bugzilla — 2019-12-20T18:20:35Z
Looks like this is fixed, isn't it?
Comment #8 by schveiguy — 2019-12-21T03:56:22Z
Yep, this was before dlangbot was around helping us close bugs when PRs were pulled. We forgot to close this when my PR was pulled. Thanks for helping to clean up these things!