dockimbel/Red — Issue #192: EITHER expression not working as argument to a typed function call
Author: dockimbel
Created: 2011-12-24 15:39:26+00:00
State: open

An `either` expression passed as argument to a typed function will have its return value corrupted by other arguments.

Example:

```
foo: func [a [byte!] return: [byte!]][a]
print ["hello" either true [" world"][newline] foo lf]
```

will print `hello` instead of `hello world`.

The ARM emitter is more sensible to this issue than the IA-32 one, because of its need for passing memory data through registers before pushing them on stack. So, for simple use cases, the IA-32 emitter will generate correct code, but anyway, you should not rely on this construction for now in your programs until a fix or workaround is found.

As a change to the semantics of `either` might be required to fix cleanly this issue, it might be postponed until Red/System full rewrite in Red.

A simple workaround for this issue exists right now: just assign the result of the `either` expression to a local variable and pass that variable as argument to the typed function.