Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skeleton of a language reference. #4808

Merged

Conversation

tangent-vector
Copy link
Contributor

The files being checked in here were initially written 2-3 years ago. They are very clearly incomplete, outdated and, quite often, inaccurate.

The intention of this change is to get an initial skeleton in place for the large-scale structure of a language reference (for now avoiding the term "specification" and all the weight it carries). Future commits should be able to add to flesh out this skeleton and start to make the document more complete and more accurate.

The files being checked in here were initially written 2-3 years ago.
They are very clearly incomplete, outdated and, quite often, inaccurate.

The intention of this change is to get an initial skeleton in place for
the large-scale structure of a language reference (for now avoiding
the term "specification" and all the weight it carries).
Future commits should be able to add to flesh out this skeleton and
start to make the document more complete and more accurate.
@tangent-vector tangent-vector added kind:documentation areas where we can improve documentation in codebase pr: non-breaking PRs without breaking changes labels Aug 8, 2024
Identifiers
-----------

An _identifier_ begins with an uppercase or lowercase ASCII letter (`A` through `Z`, `a` through `z`), or an underscore (`_`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be any unicode character now.

The condition may be either a single value of type `bool`, or a vector of `bool`.
When a vector of `bool` is used, the two values being selected between must be vectors, and selection is performed component-wise.

> Note: Unlike C, C++, GLSL, and most other C-family languages, Slang currently follows the precedent of HLSL where `?:` does not short-circuit.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do short-circuit by default now.


### If Statement

An _if statement_ consists of the `if` keyword and a conditional expression in parentheses, followed by a statement to execute if the condition is true:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have
if (let x = optionalValue), where optionalValue is Optional<T> and x is T.


The value returned must be able to coerce to the result type of the lexically enclosing function.

### Discard Statement
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also __target_switch.


Operations with side effects that were executed by the invocation before a `discard` will still be performed and their results will become visible according to the rules of the platform.

Compile-Time For Statement
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove this.

}
```

It is an error to declare an associated type anywhere other than the body of an interface declaration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to cover type constraints on associated types?

{
...

__subscript(int index) -> float
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also support multi parameter __subscript.

In general, the order of declarations within a source unit does not matter; declarations can refer to other declarations (of types, functions, variables, etc.) later in the same source unit.
Declarations (other than `import` declarations) may freely be defined in any source unit in a module; declarations in one source unit of a module may freely refer to declarations in other source units.

Imports
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also need to discuss visibility modifiers.

Attributes
==========

> Note: This section is not yet complete.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to talk about user defined attributes here.

* [5 - Expressions](05-expressions.md)
* [6 - Statements](06-statements.md)
* [7 - Declarations](07-declarations.md)
* [8 - Attributes](08-attributes.md)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have another section on the capability system?

Types in Slang do not necessarily prescribe a single _layout_ in memory.
The discussion of each type will specify any guarantees about layout it provides; any details of layout not specified here may depend on the target platform, compiler options, and context in which a type is used.

Void Type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should talk about Optional

| `\|=` | Assignment | compound bitwise or/assign |
| `^=` | Assignment | compound bitwise xor/assign |
| `=` | Assignment | assignment |
| `,` | Sequencing | sequence |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also have is and as operators.

@tangent-vector tangent-vector merged commit e4088cd into shader-slang:master Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:documentation areas where we can improve documentation in codebase pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants