On Thursday, 10 December 2020 at 05:49:12 UTC, 9il wrote:
On Wednesday, 9 December 2020 at 14:34:18 UTC, Andre Pany wrote:
[...]

For .member access mir.algebraic checks at compile time that all underlying types (except typeof(null)) can be called with provided arguments. It is kind of API protection.

Alternatives:

With compile-time known type
```
v.get!A.foo(3); // will throw if it isn't A
v.trustedGet!A.foo(3); // will assert if it isn't A
```

Without compile-time known type
```
v.tryGetMember!"foo"(3); // will throw if it isn't A
v.optionalGetMember!"foo"(3); // will return null Nullable!void of it isn't A
```

tryGetMember and optionalGetMember are alternative visitor handlers in mir.algebraic.

Kind regards,
Ilya

Fantastic, thanks a lot!

Kind regards
André

Reply via email to