diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-24 20:17:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-24 20:17:46 -0700 |
| commit | 666af0962b6ab41489a3a3287db83f77c2f6461a (patch) | |
| tree | 81a1247188ac03f1e8132e58ec31ae0f28c8c530 /source/slang/core.meta.slang | |
| parent | 7292edbd3eba3da7e8490ad19169a7d18283057a (diff) | |
Switch to short circuiting semantics for scalar `?:` operator. (#2733)
Diffstat (limited to 'source/slang/core.meta.slang')
| -rw-r--r-- | source/slang/core.meta.slang | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 6581cc605..82a60a612 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -315,13 +315,18 @@ U operator,(T left, U right) return right; } -// The ternary `?:` operator does not short-circuit in HLSL, and Slang continues to -// follow that definition, so that this operator is effectively just an ordinary -// function, rather than a special-case piece of syntax. -// +// The ternary `?:` operator does not short-circuit in HLSL, and Slang no longer +// follow that definition for the scalar condition overload, so this declaration just serves +// for type-checking purpose only. + __generic<T> __intrinsic_op(select) T operator?:(bool condition, T ifTrue, T ifFalse); __generic<T, let N : int> __intrinsic_op(select) vector<T,N> operator?:(vector<bool,N> condition, vector<T,N> ifTrue, vector<T,N> ifFalse); +// Users are advised to use `select` instead if non-short-circuiting behavior is intended. +__generic<T> __intrinsic_op(select) T select(bool condition, T ifTrue, T ifFalse); +__generic<T, let N : int> __intrinsic_op(select) vector<T,N> select(vector<bool,N> condition, vector<T,N> ifTrue, vector<T,N> ifFalse); + + ${{{{ // We are going to use code generation to produce the // declarations for all of our base types. |
