digitalmars.D.learn - Making template instantiations more lazy
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (4/4) Oct 18 2017 Are there any nearby plans to make more template instantiations
- Jonathan M Davis (7/11) Oct 18 2017 Templates are never instantiated unless they're actually... well,
- =?UTF-8?B?Tm9yZGzDtnc=?= (3/15) Oct 18 2017 Member functions of templated containers is my main focus.
- Biotronic (7/24) Oct 18 2017 Make them templates, that should solve the problem:
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/9) Oct 18 2017 Yeah I've thought of that.
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/4) Oct 18 2017 Would such a change cause any serious breakage?
- Biotronic (9/15) Oct 18 2017 Seems unlikely - when did you last use a function without using
- =?UTF-8?B?Tm9yZGzDtnc=?= (4/11) Oct 18 2017 I wonder if the fix simple (to Walter at least).
- Jonathan M Davis (14/28) Oct 18 2017 If you actually needed all of the member functions to fully exist, that
Are there any nearby plans to make more template instantiations (especially aggregate members) lazy in DMD? Are there any specific obstacles against doing that or has it just not been prioritized?
Oct 18 2017
On Wednesday, October 18, 2017 09:13:47 Per Nordlöw via Digitalmars-d-learn wrote:Are there any nearby plans to make more template instantiations (especially aggregate members) lazy in DMD? Are there any specific obstacles against doing that or has it just not been prioritized?Templates are never instantiated unless they're actually... well, instantiated. So, they're already lazy in that sense. The compiler isn't pre-emptive with them at all. What exactly about them do you want to be lazy that isn't? - Jonathan M Davis
Oct 18 2017
On Wednesday, 18 October 2017 at 09:32:39 UTC, Jonathan M Davis wrote:On Wednesday, October 18, 2017 09:13:47 Per Nordlöw via Digitalmars-d-learn wrote:Member functions of templated containers is my main focus.Are there any nearby plans to make more template instantiations (especially aggregate members) lazy in DMD? Are there any specific obstacles against doing that or has it just not been prioritized?Templates are never instantiated unless they're actually... well, instantiated. So, they're already lazy in that sense. The compiler isn't pre-emptive with them at all. What exactly about them do you want to be lazy that isn't? - Jonathan M Davis
Oct 18 2017
On Wednesday, 18 October 2017 at 09:56:33 UTC, Nordlöw wrote:On Wednesday, 18 October 2017 at 09:32:39 UTC, Jonathan M Davis wrote:Make them templates, that should solve the problem: struct S(T) { void foo()() { compileerror; } }On Wednesday, October 18, 2017 09:13:47 Per Nordlöw via Digitalmars-d-learn wrote:Member functions of templated containers is my main focus.Are there any nearby plans to make more template instantiations (especially aggregate members) lazy in DMD? Are there any specific obstacles against doing that or has it just not been prioritized?Templates are never instantiated unless they're actually... well, instantiated. So, they're already lazy in that sense. The compiler isn't pre-emptive with them at all. What exactly about them do you want to be lazy that isn't? - Jonathan M Davis
Oct 18 2017
On Wednesday, 18 October 2017 at 10:17:38 UTC, Biotronic wrote:Make them templates, that should solve the problem: struct S(T) { void foo()() { compileerror; } }Yeah I've thought of that. I still would like to have it built-in to the compiler.
Oct 18 2017
On Wednesday, 18 October 2017 at 10:36:41 UTC, Per Nordlöw wrote:Yeah I've thought of that. I still would like to have it built-in to the compiler.Would such a change cause any serious breakage?
Oct 18 2017
On Wednesday, 18 October 2017 at 10:55:49 UTC, Per Nordlöw wrote:On Wednesday, 18 October 2017 at 10:36:41 UTC, Per Nordlöw wrote:Seems unlikely - when did you last use a function without using it? :p I'm not actually sure why D behaves this way - C++ doesn't. I guess there is some value as tests - instantiating the type tests that all its methods compile. Not actually sure that's more of a positive than a negative, but it's certainly never bothered me. -- BiotronicYeah I've thought of that. I still would like to have it built-in to the compiler.Would such a change cause any serious breakage?
Oct 18 2017
On Wednesday, 18 October 2017 at 11:18:31 UTC, Biotronic wrote:I'm not actually sure why D behaves this way - C++ doesn't. I guess there is some value as tests - instantiating the type tests that all its methods compile. Not actually sure that's more of a positive than a negative, but it's certainly never bothered me. -- BiotronicI wonder if the fix simple (to Walter at least). It would save container-heavy projects noticeable build time. Adding () to the member functions did it for mine at least.
Oct 18 2017
On Wednesday, October 18, 2017 10:36:41 Per Nordlöw via Digitalmars-d-learn wrote:On Wednesday, 18 October 2017 at 10:17:38 UTC, Biotronic wrote:If you actually needed all of the member functions to fully exist, that would make life a lot harder (e.g. if you're doing something with language bindings and need to guarantee that a particular template instantiation fully exists). And if you suddenly couldn't guarantee that everything within a template was instantiated when the template was instantiated, then you basically have code that looks like it exists but doesn't actually, and that would make it rather difficult to know what code actually exists, whereas right now, if you instantiate a template, you know exactly what code then exists because of that instantiation. At least with the ability to separately templatize member functions, you can control what's going on. - Jonathan M DavisMake them templates, that should solve the problem: struct S(T) { void foo()() { compileerror; } }Yeah I've thought of that. I still would like to have it built-in to the compiler.
Oct 18 2017