September 27, 2020
On Sunday, 27 September 2020 at 02:31:36 UTC, Andrei Alexandrescu wrote:
> On 9/26/20 8:27 PM, Adam D. Ruppe wrote:
>> On Sunday, 27 September 2020 at 00:10:33 UTC, Stefan Koch wrote:
>>> This example on the other hand works:
>> 
>> Here's another potential implementation:
>> 
>> ---
>> template sortBySize(T...) {
> [snip]
>
> Sorting by inheritance relationship is more difficult. I got this going, alpha quality:
>
> https://gist.github.com/andralex/0d85df38be2d9ffbe89cf1fb51c44213
>
> Now indeed calling std.sort against (reified) types just works.
>
> The point is to reify the bases of the type as well so they can be manipulated as objects. Then defining the comparison relation is easy (didn't bother to make it efficient here - just a linear search).
>
> More introspection-related matters would be reified the same way (store during construction in the reified object, potentially via pointers if they don't apply to all objects). Instance size would be an obvious candidate, prolly I'll put it in there as a demo. More interestingly we'd have things like parameters/return for functions and data members for classes and structs. Long way ahead.
>
> This is really exciting stuff.

We're in an early stage of exploration of discovered capability, so I understand the excitement.  The C++ guys must have been way excited about their meta programming discoveries as well.

Just a respectful reminder here: a discovered way to do something is not a designed way to do something.  Cleverness can take you a very very long way (Modern C++ anyone? :-) ) but it's unlikely that it will take you to appropriate simplicity.

Whatever decisions are made down the road, I'm happy that we're actively looking at extending D's safely accessible meta programming capabilites now.  Sounds like a great topic for beerconf-day-2.













September 26, 2020
On 9/26/2020 9:18 AM, Andrei Alexandrescu wrote:
> [...]

It's too easy. You must have done it all wrong!
September 27, 2020
On Saturday, 26 September 2020 at 16:18:27 UTC, Andrei Alexandrescu wrote:
> Commments and ideas for improvements are welcome.

Great idea.

1. I presume we need to benchmark this both in space and time to judge its merits. Have you done any such? How will the number of templates instances change with length of array for each algorithm in std.meta?

2. To reduce (all) template bloat in your new version of std.meta, what about adding a special handling in the compiler for `reify` and `dereify` like was done with `AliasSeq`?
September 27, 2020
On Saturday, 26 September 2020 at 16:18:27 UTC, Andrei Alexandrescu wrote:
> I'll start with the punchline: at the link below you'll find an alpha-quality reimplementation of std.meta in an iterative manner:
>
> https://gist.github.com/andralex/6212ebf2b38c59c96cf66d0009336318

This is really cool. It looks like if we add just a tiny bit of compiler support (like Walter's PR) we could make this efficient. And we're just using the power of CTFE to do it. Sweet.
September 27, 2020
On Sunday, 27 September 2020 at 03:46:52 UTC, Bruce Carneal wrote:
> On Sunday, 27 September 2020 at 02:31:36 UTC, Andrei Alexandrescu wrote:
>>
>
> We're in an early stage of exploration of discovered capability, so I understand the excitement.  The C++ guys must have been way excited about their meta programming discoveries as well.
>
> Just a respectful reminder here: a discovered way to do something is not a designed way to do something.  Cleverness can take you a very very long way (Modern C++ anyone? :-) ) but it's unlikely that it will take you to appropriate simplicity.

D: "Look ma I can peel an apple with a tin opener!"

Mom(C++): "That's my boy... the band-aids are in the usual place."
September 28, 2020
On Sunday, 27 September 2020 at 16:32:18 UTC, claptrap wrote:
> On Sunday, 27 September 2020 at 03:46:52 UTC, Bruce Carneal wrote:
>> On Sunday, 27 September 2020 at 02:31:36 UTC, Andrei Alexandrescu wrote:
>>>
>>
>> We're in an early stage of exploration of discovered capability, so I understand the excitement.  The C++ guys must have been way excited about their meta programming discoveries as well.
>>
>> Just a respectful reminder here: a discovered way to do something is not a designed way to do something.  Cleverness can take you a very very long way (Modern C++ anyone? :-) ) but it's unlikely that it will take you to appropriate simplicity.
>
> D: "Look ma I can peel an apple with a tin opener!"
>
> Mom(C++): "That's my boy... the band-aids are in the usual place."

Andrei and others advanced us well beyond the mandated cleverness of C++ meta programming.  As Atila has put it, they helped make things "boring" through very good design.  I deeply admire that work.

I hope and believe that there is another such advance available to us in the form of type functions.  The recently discovered alternative, reify/dereify, appears to be equivalent in power but is, comparatively, baroque.

If the two approaches are actually equivalent in power, and in their ability to address the current template issues, then the baroque should be preferred if the language is closed to syntactic additions.

If the language is not closed, then choosing to displace the already prototyped type function capability with reify/dereify would represent a lost opportunity to administer another complexity smackdown.

Disclaimer: Andrei has stated, effectively, that I have little standing to opine on these issues.  It is true that while I use templates extensively I confine myself to very simple combinations thereof.  I am not experiencing the template pain reported by others.

Best wishes to those who continue to work in this area.  Here's hoping you lead us to a future that is extremely boring.




















September 27, 2020
On 9/27/20 10:58 PM, Bruce Carneal wrote:
> Disclaimer: Andrei has stated, effectively, that I have little standing to opine on these issues.

Sorry! Didn't mean to sound dismissive at all. Meant to just say, don't shun templates, embrace them and thrive.

September 28, 2020
On Monday, 28 September 2020 at 03:03:01 UTC, Andrei Alexandrescu wrote:
> On 9/27/20 10:58 PM, Bruce Carneal wrote:
>> Disclaimer: Andrei has stated, effectively, that I have little standing to opine on these issues.
>
> Sorry! Didn't mean to sound dismissive at all. Meant to just say, don't shun templates, embrace them and thrive.

In practice template can quite literally explode though.
Which could be a valid reason to shun them.
You can embrace them, of course, and thrive.
The question is for how long you will thrive.
September 28, 2020
On 9/28/20 8:46 AM, Stefan Koch wrote:
> On Monday, 28 September 2020 at 03:03:01 UTC, Andrei Alexandrescu wrote:
>> On 9/27/20 10:58 PM, Bruce Carneal wrote:
>>> Disclaimer: Andrei has stated, effectively, that I have little standing to opine on these issues.
>>
>> Sorry! Didn't mean to sound dismissive at all. Meant to just say, don't shun templates, embrace them and thrive.
> 
> In practice template can quite literally explode though.
> Which could be a valid reason to shun them.
> You can embrace them, of course, and thrive.
> The question is for how long you will thrive.

For a very long time judging by the success C++ is enjoying with them.
September 28, 2020
On Monday, 28 September 2020 at 14:16:20 UTC, Andrei Alexandrescu wrote:
> On 9/28/20 8:46 AM, Stefan Koch wrote:
>> On Monday, 28 September 2020 at 03:03:01 UTC, Andrei Alexandrescu wrote:
>>> On 9/27/20 10:58 PM, Bruce Carneal wrote:
>>>> Disclaimer: Andrei has stated, effectively, that I have little standing to opine on these issues.
>>>
>>> Sorry! Didn't mean to sound dismissive at all. Meant to just say, don't shun templates, embrace them and thrive.
>> 
>> In practice template can quite literally explode though.
>> Which could be a valid reason to shun them.
>> You can embrace them, of course, and thrive.
>> The question is for how long you will thrive.
>
> For a very long time judging by the success C++ is enjoying with them.

As you note, by employing a variety of "best practices", of extra-language conventions, of one-level-of-indirection wrappers, of "human must certify this correct" mechanisms, the C++ community has indeed "thrived".

We've not settled for that meta programming drudgery, that friction, in the past.  You know better this better than anyone else on the planet.  I hope we don't "settle" going forward.