mixin does not work as expected

rempas rempas at tutanota.com
Wed Jan 5 10:47:44 UTC 2022


On Wednesday, 5 January 2022 at 09:33:07 UTC, vit wrote:
> 2) if-else must be in same mixin:
> ```d
>     mixin(""
>         + type_check!("static if", "i8", "true", "5", "4", 
> "10", "5")
>         + type_check!("else static if", "i16", "true", "7", 
> "6", "18", "8")
>     	+ type_check!("else static if", "i32", "true", "12", "10", 
> "34", "13")
>     	+ type_check!("else", "i64", "true", "21", "18", "66", 
> "24")
>     );
> ```

Yeah, sorry, you added the last comment (before this one) after I 
posted mine. Also, the fact that they must be in the same mixin 
is what I said that the problem is but thankfully there is a way 
around it. Tho this code will still not work. First, we must 
change "+" to "~" to concatenate strings but still, I'm getting 
the following error:

```
test.d-mixin-27(47): Error: found `End of File` when expecting 
`;` following statement
test.d(45): Error: template instance `test.test!true` error 
instantiating
```

There may be a problem in the "type_check" enum but I wanted to 
post this reply before I search any any case there is something 
else happening and you happen to know. I will update if I found it

> 3) last type_checkin signed and unsigned part of function test 
> has else with condition.
>
> ```d
> else(is_same!(num, i64)) {
>     mixin(base_digit!("21", "18", "66", "24"));
>     static if (true) {
>       mixin(overflow_check!"i64.min"); }
>   }
> ```

What does this mean? Yes they do, the else is used to mach the 
64-bit type.


More information about the Digitalmars-d-learn mailing list