[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inline VALOF
>occam expressions are very powerful: side-effect free, able to be reasoned
>about simply, able to be parallelised trivially. Conditional expressions
>would increase that power and I've always fancied them - e.g.:
> <boolean-exp> -> <exp>, <exp>
>Indeed, we put "->" into the compiler ages ago as a reserved symbol with
>the above in mind ... but never got around to it. Then, instead of:
> IF
> urgent
> delay := 1*weeks
> TRUE
> delay := 2*weeks
>
>we could write:
> delay := urgent -> 1*weeks, 2*weeks
>which kind of thing happens quite a lot!??
>I don't see any semantic problem with conditional expressions - the two
>expressions on the RHS must have, of course, matching types.
Since we added user-defined operators, you can write:
INT INLINE FUNCTION "??" (VAL BOOL b, VAL [2]INT x) IS x[INT b]:
(overloaded for any types you like), and then
delay := (urgent ?? [1, 2]) * weeks
The only problem I can think of is that both expressions (1 and 2 above)
are evaluated.
(And that it's the wrong way round -- make that x[1 - (INT b)] or
x[INT (NOT b)].)
David