Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-28 Thread Mark via Digitalmars-d
On Wednesday, 27 December 2017 at 16:36:59 UTC, H. S. Teoh wrote: On Tue, Dec 26, 2017 at 11:28:56AM +, Mark via Digitalmars-d wrote: On Monday, 25 December 2017 at 22:48:39 UTC, H. S. Teoh wrote: > [...] Maybe we can document the interface of the return type using signature constraints?

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-27 Thread H. S. Teoh via Digitalmars-d
On Tue, Dec 26, 2017 at 01:50:06AM +, Neia Neutuladh via Digitalmars-d wrote: > On Monday, 25 December 2017 at 22:48:39 UTC, H. S. Teoh wrote: > > The exact type does not and should not need to be known by user > > code. > > It's a public type reported by some of the documentation but not

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-27 Thread Neia Neutuladh via Digitalmars-d
On Wednesday, 27 December 2017 at 16:36:59 UTC, H. S. Teoh wrote: The best we can do currently, which unfortunately won't show up in the docs, is to use a static assert to force compilation failure when the return type doesn't match expectations, e.g.: [...] static

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-27 Thread H. S. Teoh via Digitalmars-d
On Tue, Dec 26, 2017 at 11:28:56AM +, Mark via Digitalmars-d wrote: > On Monday, 25 December 2017 at 22:48:39 UTC, H. S. Teoh wrote: > > While I agree that all template parameters ought to be documented > > and all auto return types thoroughly described, I disagree with > > explicit naming of

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-26 Thread Piotr Klos via Digitalmars-d
On Monday, 25 December 2017 at 22:48:39 UTC, H. S. Teoh wrote: On Mon, Dec 25, 2017 at 04:26:52PM +, Piotr Klos via Digitalmars-d wrote: On Monday, 25 December 2017 at 03:23:33 UTC, Neia Neutuladh wrote: > If you have a function with a return type listed as `auto`, > please thoroughly

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-26 Thread Mark via Digitalmars-d
On Monday, 25 December 2017 at 22:48:39 UTC, H. S. Teoh wrote: While I agree that all template parameters ought to be documented and all auto return types thoroughly described, I disagree with explicit naming of auto return types. The whole point of auto return types is to return an *opaque*

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-25 Thread Neia Neutuladh via Digitalmars-d
On Monday, 25 December 2017 at 22:48:39 UTC, H. S. Teoh wrote: The exact type does not and should not need to be known by user code. It's a public type reported by some of the documentation but not other parts. Its capabilities are given vaguely in the docs for the functions that return it.

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-25 Thread H. S. Teoh via Digitalmars-d
On Mon, Dec 25, 2017 at 04:26:52PM +, Piotr Klos via Digitalmars-d wrote: > On Monday, 25 December 2017 at 03:23:33 UTC, Neia Neutuladh wrote: > > If you have a function with a return type listed as `auto`, please > > thoroughly describe what interface the return value provides. > > > > I

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-25 Thread Piotr Klos via Digitalmars-d
On Monday, 25 December 2017 at 03:23:33 UTC, Neia Neutuladh wrote: If you have a function with a return type listed as `auto`, please thoroughly describe what interface the return value provides. I would just like to say that I strongly agree. Lack of documentation of template parameters

Re: Please do not use 'auto' return types without thoroughly describing the interface

2017-12-24 Thread rikki cattermole via Digitalmars-d
I would like to fix this using signatures[0]. Signatures have a number of benefits here, including removing of TypeInfo (which prevents code-bloat). There is a few other examples based upon allocators here[1]. But this isn't a short term goal even if it does get approved ;) [0]

Please do not use 'auto' return types without thoroughly describing the interface

2017-12-24 Thread Neia Neutuladh via Digitalmars-d
If you have a function with a return type listed as `auto`, please thoroughly describe what interface the return value provides. "Returns a forward range of Elem", where Elem is a template parameter, is fine, for instance. But look at std.regex.RegexMatch.front: "Functionality for