diff options
| author | Yong He <yonghe@outlook.com> | 2023-12-06 15:52:02 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-06 15:52:02 -0800 |
| commit | 8102e5ee81db177372bb90188c65d003a4907aa4 (patch) | |
| tree | 2ea145d7a58abe395e1765009bc943d97933104b /docs/user-guide/03-convenience-features.md | |
| parent | 11111e5733b189127dc2c4934d67693b9bc6e764 (diff) | |
Change default visibility of interface members and update docs. (#3381)
* Update behavior around interfaces and docs.
* Update toc
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'docs/user-guide/03-convenience-features.md')
| -rw-r--r-- | docs/user-guide/03-convenience-features.md | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md index 3155cd1b5..74676699f 100644 --- a/docs/user-guide/03-convenience-features.md +++ b/docs/user-guide/03-convenience-features.md @@ -395,50 +395,3 @@ by using the `[ForceInline]` decoration: [ForceInline] int f(int x) { return x + 1; } ``` - -Modules -------- - -While you can still organize code using preprocessor `#include`s, Slang also supports a _module_ system. - -### Importing a Module - -At the global scope of a Slang file, you can use the `import` keyword to import another module by name: - -```hlsl -// MyShader.slang - -import YourLibrary; -``` - -This `import` declaration will cause the compiler to look for a module named `YourLibrary` and make its declarations visible in the current scope. -Currently, the compiler will load the module by looking for source file with a matching name (`YourLibrary.slang`) in any of its configured search paths. - -Multiple `import`s of the same module from different input files will only cause the module to be loaded once (there is no need for "include guards" or `#pragma once`). -Note that preprocessor definitions in the current file will not affect the compilation of `import`ed code. - -> #### Note #### -> Future versions of the Slang system will support loading of modules from pre-compiled binaries instead of source code. -> The same `import` keyword will continue to work in that case. - -### Defining a Module - -If you decide to organize your code into modules, then the simplest way is to have each module consist of a single `.slang` file. -Any declarations in your module -- types, functions, etc. -- will be visible to clients that `import` it. - -> #### Note #### -> Any preprocessor definitions inside your module will not be visible to clients; -> as a result you may find it best to switch to `static const` for defining constants. - -> #### Note #### -> A future version of the Slang compiler may support using access-control keywords (such a `public`) to control which declarations in a module are visible to clients. - -Your module may depend on other modules using `import`. -By default, the symbols that are imported into your module are *not* made visible to clients who `import` your module. -You can override this default by using an _exported_ `import`: - -```hlsl -__export import SomeOtherModule; -``` - -This line imports `SomeOtherModule` into the current module, and also re-exports all of the imported symbols from the current module, so that they appear as part of its public interface. |
