This one weird trick allows you to capture loop variables.

Meta jared771 at gmail.com
Thu Oct 24 21:35:56 UTC 2024


On Thursday, 24 October 2024 at 00:46:48 UTC, Timon Gehr wrote:
> On 10/24/24 01:00, Elias (0xEAB) wrote:
>> On Sunday, 20 October 2024 at 22:45:24 UTC, Timon Gehr wrote:
>>> As someone who has also implemented `opApply`, I do think it 
>>> is quite straightforward. It's just internal iteration with 
>>> support for multiple ways to exit the loop, encoded using 
>>> numerical indices.
>> 
>> Do you have any suggestions or insights how we could resolve 
>> its rather poor compatibility with the attribute soup?
>
> Attribute polymorphism. It's a common feature in other effect 
> systems, and it is generally useful.
>
> Another solution is to avoid attributes. :)

Do you count languages with effects systems like Koka count as 
having effect polymorphism? I've studied them a bit, and it is a 
deep, deep rabbit hole that D could go down for not that much 
benefit. Or would you limit such a system to something like:

void map(T, U, effect Es...)(t[] a, U function(T) <Es> fun) <Es>; 
// Strawman syntax, I dunno

Where it's solely polymorphism over effects and there isn't all 
this complicated stuff like effect types and handlers, etc.


More information about the Digitalmars-d mailing list