-
Notifications
You must be signed in to change notification settings - Fork 245
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
Add skeleton of a language reference. #4808
Conversation
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.
Identifiers | ||
----------- | ||
|
||
An _identifier_ begins with an uppercase or lowercase ASCII letter (`A` through `Z`, `a` through `z`), or an underscore (`_`). |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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.
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.