diff --git a/content/language-features/basics.md b/content/language-features/basics.md index a11a164..ebdd7c7 100644 --- a/content/language-features/basics.md +++ b/content/language-features/basics.md @@ -5,8 +5,6 @@ date = 2025-05-08T22:23:44-05:00 This is a book for my language found [here](https://crosslang.tesseslanguage.com/) - - ## Statements and loops @@ -25,6 +23,25 @@ var myVariable = 42; myVariable = "I have set the variable to a string"; ``` +#### Reflective variables + +```js +var nameOfVariable = "Var 1"; +.[nameOfVariable] = 42; //the variable name in this instance will be Var 1 +Console.WriteLine(.[nameOfVariable]); //prints 42 + + +var nameOfVariable2 = "Var 2"; +var nameOfField = "This field has spaces and \n New Lines"; +.[nameOfVariable2] = { + .[nameOfField] = "Hello, world" +}; + +Console.WriteLine(.[nameOfVariable2].[nameOfField]); //should print Hello, world + +``` + + #### If statements The {} are optional if you only need one statement @@ -118,7 +135,7 @@ do(conditionLikeIf) #### Try statement -Note: you can't yield, return, break or continue from inside a try statement (also applys to catch and finally due to these being internally closures) +NOTE: you can't return undefined (but you can return other types) (It will just return from try and will still execute the body past the try statement) due to the try statement being a closure (you can still break and continue due to special TObjects being returned) ```js try { @@ -583,3 +600,26 @@ myHtml = Hello; //would just be Hello (useful for templating as it myHtml = ; //allowing you to emit unescaped html from string into html litteral (useful for templating) ``` + + + + + + + + + + + + + + + + + + + + + + +