ternary op assign

monkyyy crazymonkyyy at gmail.com
Thu May 16 17:30:41 UTC 2024


On Thursday, 16 May 2024 at 16:57:17 UTC, Quirin Schroll wrote:
> On Thursday, 2 May 2024 at 17:42:28 UTC, monkyyy wrote:
>> `foo?=bar:baz` is rewritten as `foo.opOpAssign!("?:")(bar,baz)`
>>
>> `foo[i]?=bar:baz` opIndexOpAssign
>>
>> for basic types it acts as `foo=(bool)bar?foo:(typeof(foo))baz`
>
> Isn’t this just `if (!bar) foo = baz;`?
>
> Where would the user-defined operator be useful?

when bar depends on foo; such as a user defined cond, lets saya 
database query that takes in lamdas

`foo?=a=>a%2:baz`

and when its "multiable data single instruction", simd or 
parrellizism, ranges etc. and theres something in that index
you can not write `if(!bar[foo's slice????]) foo=baz[...];`





More information about the dip.ideas mailing list