summaryrefslogtreecommitdiffstats
path: root/docs/user-guide
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-21 17:19:03 -0700
committerGitHub <noreply@github.com>2024-03-21 17:19:03 -0700
commit7a8ef896196ad0d7095412d8558dd9a2542874c8 (patch)
treedeef82a216f468fd57164f94700f2624164c7ca9 /docs/user-guide
parentdd32414bd7332c55dc37ea2972ffcca73328d834 (diff)
Support arrow operator `->` on pointers. (#3812)
Diffstat (limited to 'docs/user-guide')
-rw-r--r--docs/user-guide/03-convenience-features.md8
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md
index ca4635df4..a325f64f3 100644
--- a/docs/user-guide/03-convenience-features.md
+++ b/docs/user-guide/03-convenience-features.md
@@ -363,19 +363,21 @@ float4 myPackedVector = reinterpret<float4>(myVal);
## Pointers
-Slang supports pointers when generating code for SPIRV, C++ and CUDA targets. The syntax for pointers is similar to C, with the exception that operator `.` can also be used to dereference a member. Slang currently does not support the `->` operator.
-For example:
+Slang supports pointers when generating code for SPIRV, C++ and CUDA targets. The syntax for pointers is similar to C, with the exception that operator `.` can also be used to dereference a member from a pointer. For example:
```csharp
int test(MyType* pObj)
{
MyType* pNext = pObj + 1;
MyType* pNext = &pNext[1];
- return pNext.a + (*pNext).a + pNext[0].a;
+ return pNext.a + pNext->a + (*pNext).a + pNext[0].a;
}
```
Pointer types can also be specified using the generic syntax: `Ptr<MyType>` is equivalent to `MyType*`.
+> #### Note
+> Slang currently does not support pointers to immutable values, i.e. `const T*`.
+
## `struct` inheritance (limited)
Slang supports a limited form of inheritance. A derived `struct` type has all the members defined in the base type it is inherited from: