Replies: 3 comments 4 replies
-
I think it might make the most sense to have directives be an alternative syntax for invoking compile-time functions/macros. Specifically, ones that take in structs/functions/enums and modify them in some way, and finally return an equivalent transformed definition (s). However, given that this is not part of the language yet, it might be better to keep them as internal for now, generally used for debugging purposes or common transformations (serde, memoisation, etc). |
Beta Was this translation helpful? Give feedback.
-
Also, should multiple directives be separated by commas, or just spaces? we would require no extra syntax in the latter case, other than precedence rules. |
Beta Was this translation helpful? Give feedback.
-
Another thing to note is we might want to support higher order functions here, like |
Beta Was this translation helpful? Give feedback.
-
Oveview
Language directives are a way to signal to the compiler to perform a particular behaviour. The directive can be used to mark an expression that the compiler will then perform the specified directive on.
The syntax would follow:
and for multiple directives, this can be used:
This means that directives follow the standard identifier syntax preceded with a
#
.Directives have many uses, for example:
This could mean that the compiler would inline particular logic that would memoise function calls to
the function
fact
and re-use values instead of re-computing this.Problems
#
for intrinsic functions and directives. If directives are to be added to the language, then we either have to re-define the syntax for intrinsic functions or use an alternative syntax for intrinsic functions.Beta Was this translation helpful? Give feedback.
All reactions