summaryrefslogtreecommitdiff
path: root/docs/user-guide/04-interfaces-generics.md
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-12-21 12:00:22 -0500
committerGitHub <noreply@github.com>2021-12-21 12:00:22 -0500
commit48530f4c3505d1ab6269a5c21881492f059538d6 (patch)
tree0119503ea218fb578096ead8ae4e8c9ae5a2241e /docs/user-guide/04-interfaces-generics.md
parentf813d5f20b3aa839a7865be483d4c89ac63d8e19 (diff)
Hotfix/doc typos4 (#2067)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix some typos. * Fix some more typos.
Diffstat (limited to 'docs/user-guide/04-interfaces-generics.md')
-rw-r--r--docs/user-guide/04-interfaces-generics.md4
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/user-guide/04-interfaces-generics.md b/docs/user-guide/04-interfaces-generics.md
index 45273618c..65c23d98e 100644
--- a/docs/user-guide/04-interfaces-generics.md
+++ b/docs/user-guide/04-interfaces-generics.md
@@ -18,7 +18,7 @@ interface IFoo
}
```
-Slang's syntax for defining interfaces are similar to `interface`s in C# and `protocal`s in Swift. In this example, the `IFoo` interface establishes a contract that any type conforming to this interface must provide a method named `myMethod` that accepts a `float` argument and returns an `int` value.
+Slang's syntax for defining interfaces are similar to `interface`s in C# and `protocol`s in Swift. In this example, the `IFoo` interface establishes a contract that any type conforming to this interface must provide a method named `myMethod` that accepts a `float` argument and returns an `int` value.
A `struct` type may declare its conformance to an `interface` via the following syntax:
```csharp
@@ -91,7 +91,7 @@ You may explicitly specify the concrete type to used for the generic type argume
Note that it is important to associate a generic type parameter with a type constraint. In the above example, although the definition of `myGenericMethod` is agnostic of the concrete type `T` will stand for, knowing that `T` conforms to `IFoo` allows the compiler to type-check and pre-compile `myGenericMethod` without needing to substitute `T` with any concrete types first. Similar to languages like C#, Rust, Swift and Java, leaving out the type constraint declaration on type parameter `T` will result in a compile error at the line calling `arg.myMethod` since the compiler cannot verify that `arg` has a member named `myMethod` without any knowledge on `T`. This is a major difference of Slang's generics compared to _templates_ in C++.
-While C++ templates is a powerful language mechanism, Slang has followed the path of many other modern programming langauges to adopt the more structural and restricted generics feature instead. This enables the Slang compiler to perform type checking early to give more readable error messages, and to speed-up compilation by reusing a lot of work for different instantiations of `myGenericMethod`.
+While C++ templates are a powerful language mechanism, Slang has followed the path of many other modern programming languages to adopt the more structural and restricted generics feature instead. This enables the Slang compiler to perform type checking early to give more readable error messages, and to speed-up compilation by reusing a lot of work for different instantiations of `myGenericMethod`.
Supported Constructs in Interface Definitions