www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Thoughts on Herb Sutter's Metaclasses?

reply Chris Katko <ckatko gmail.com> writes:
https://www.youtube.com/watch?v=6nsyX37nsRs

I'm really happy with the way languages are finally progressing. 
I've said for years that we should be able to program the "rules" 
(e.g. code guidelines) that programmers then abide by, so that 
they are statically checked.

DScanner is an example. But the core flaw is... it's "rules of 
thumb". That's great. But what about "rules for MY projects" or 
"rules for THIS SPECIFIC CODE TEAM."

I love D's templates. I'm doing stuff I never thought possible 
like accidentally re-inventing Pass-by-Name / "Named Parameters" 
completely at compile-time / zero run-time overhead.

https://en.wikipedia.org/wiki/Named_parameter

Anyhow, I wonder what the D community thinks about this kind of 
meta-programming, and how much D already can do without 
metaclasses, and whether D could possibly benefit from 
implementing them.

Thanks.
Apr 09 2018
parent reply Chris Katko <ckatko gmail.com> writes:
One more note: It seems like this would be heaven for trying out 
new language features without having to "manually" add them into 
the compiler first. By hijacking the syntax to AST stage, we can 
add new constructs with real-functioning code, and have others 
evaluate themselves and unit test them without having to 
"imagine" whether the code would actually work. It'd be on a real 
binary, using a real (unmodified!) compiler.

And you can also have your own "in-house" specializations. Which 
is no different than expecting people to use your API. Some API's 
have method chaining, and you use it. Some have pass-by-name, and 
you use it.
Apr 09 2018
parent reply Joakim <dlang joakim.fea.st> writes:
On Tuesday, 10 April 2018 at 01:21:07 UTC, Chris Katko wrote:
 One more note: It seems like this would be heaven for trying 
 out new language features without having to "manually" add them 
 into the compiler first. By hijacking the syntax to AST stage, 
 we can add new constructs with real-functioning code, and have 
 others evaluate themselves and unit test them without having to 
 "imagine" whether the code would actually work. It'd be on a 
 real binary, using a real (unmodified!) compiler.

 And you can also have your own "in-house" specializations. 
 Which is no different than expecting people to use your API. 
 Some API's have method chaining, and you use it. Some have 
 pass-by-name, and you use it.
See previous forum thread on the topic, with Walter chiming in a bit too: https://forum.dlang.org/thread/kglnxqbcugerhynngewp forum.dlang.org
Apr 09 2018
parent reply Chris Katko <ckatko gmail.com> writes:
On Tuesday, 10 April 2018 at 05:55:06 UTC, Joakim wrote:
 On Tuesday, 10 April 2018 at 01:21:07 UTC, Chris Katko wrote:
 [...]
See previous forum thread on the topic, with Walter chiming in a bit too: https://forum.dlang.org/thread/kglnxqbcugerhynngewp forum.dlang.org
Wow, that thread had very little discussion, and a huge amount of bickering over whether someone actually understood what someone else might have said.
Apr 10 2018
next sibling parent 12345swordy <alexanderheistermann gmail.com> writes:
On Tuesday, 10 April 2018 at 09:32:49 UTC, Chris Katko wrote:
 On Tuesday, 10 April 2018 at 05:55:06 UTC, Joakim wrote:
 On Tuesday, 10 April 2018 at 01:21:07 UTC, Chris Katko wrote:
 [...]
See previous forum thread on the topic, with Walter chiming in a bit too: https://forum.dlang.org/thread/kglnxqbcugerhynngewp forum.dlang.org
Wow, that thread had very little discussion, and a huge amount of bickering over whether someone actually understood what someone else might have said.
...I'm sorry?
Apr 10 2018
prev sibling parent jmh530 <john.michael.hall gmail.com> writes:
On Tuesday, 10 April 2018 at 09:32:49 UTC, Chris Katko wrote:
 Wow, that thread had very little discussion, and a huge amount 
 of bickering over whether someone actually understood what 
 someone else might have said.
My take-away was that it can be done in D, but would be simpler with AST macros and Walter is against AST macros.
Apr 10 2018