<p>Welcome to the Solstice docs! Feel free to read in whichever order you like, or come back when you feel like it. You can read these head to tail if you want to understand the whole of the language as well.</p>
<p>See a mistake? Report it at <ahref="https://chsp.au/max/sols.dev">this site's repository</a>.
<p>Happy coding!</p>
<divid="core_concepts">
<h2>Core Concepts</h2>
<p>Solstice is a high level programming language. It compiles to Ground's bytecode.</p>
<h3>The <code>solstice</code> command</h3>
<p>Solstice's compiler is invoked via the <code>solstice</code> command. It provides some options:</p>
<ul>
<li><code>-o</code> or <code>--output</code>: Tells Solstice where to output a compiled file.</li>
<li><code>-t</code> or <code>--type</code>: Tells Solstice the type of file to output.<br>At present, Solstice only supports Ground source files as an output type, but more types may be added in future.</li>
<p>Solstice code consists of four main things: values, identifiers, operators, and code blocks.</p>
<ul>
<li>Values: these are your literal values in your program, like <code>"Hello!"</code>, <code>32</code>, or <code>true</code>. More on values and the Solstice type system later.</li>
<li>Identifiers: these are names of variables. They normally hold something in them.</li>
<li>Operators: these make up the actual logic of your program. Operators are thing like <code>+</code>, <code>=</code>, or <code>if</code>. (if and while are operators in Solstice.)</li>
<li>Code blocks: this is the collection of values, identifiers, and operators, usually in between <code>{</code> and <code>}</code>.</li>
<p>The <code>puts</code> command in Solstice is used to print out a value. It is not a function, but a built in operator, similar to <code>+</code> or <code>=</code>.</p>
<p>Use it like this:</p>
<preclass="code"><code>puts "Hello, World!"
puts 3.14
puts true
puts "You can print out anything with puts!"</code></pre>
<h3>Variables</h3>
<p>Solstice variables are quite simple. Assign values with <code>=</code>, and read them with the variable name.</p>
<preclass="code"><code>x = 5 + 3<br>y = 10<br>puts x + y</code></pre>
<h3>Control Flow and Equalities</h3>
<p>Solstice supports <code>if</code> and <code>while</code> statements, as well as the <code>==</code>, <code>!=</code>, <code>></code>, <code>>=</code>, <code><</code>, and <code><=</code> operations.</p>
<p>Conditionals work just like maths: two values on either side, check whether the condition is correct or not based on those values, and output a boolean.</p>
<p><strong>Note:</strong> Functions in Solstice are currently in beta. Type checking for functions is currently experimental, and arguments may not work as intended. Be warned!</p>
<p>In Solstice, function definitions have a syntax like this: <preclass="code"><code>def functionName(type arg1, type arg2, type arg3) returnType {<br> // code goes here<br>}</code></pre></p>
<p>Your types can be <code>int</code>, <code>double</code>, <code>string</code>, <code>bool</code>, or <code>char</code> (see the "Type System" section for more details)</p>
<p>Return a value (which must be the same type as your <code>returnType</code>) with <code>return value</code>.</p>
<p>Here's an example function:</p>
<preclass="code"><code>def add(int a, int b) int {
return a + b
}</code></pre>
<h3>Calling Functions</h3>
<p>Function calling is done like in most other programming languages, with the syntax <code>function(arg1, arg2, arg3)</code>.</p>
<h3>That's it!</h3>
<p>You now know everything you need to know about Solstice to start programming! You can continue reading for more information.</p>
<p>Since Solstice is built atop Ground, you can write Ground code inside Solstice code, usually to wrap a Ground function for the Solstice standard library.</p>
<p>Inline Ground is not vetted by the type checker. <strong>Be careful when modifying existing variables with inline ground!</strong> The type checker is not aware of any values created inside inline Ground.</p>
<p>If you would like the Solstice type checker to be aware of values created by Ground, initialise a variable with a blank of whatever type is made by Ground.</p>
<p>Variable names are the same inside inline Ground as they are in Solstice. Read Ground's syntax guide for an understanding on how it should work <ahref="https://chookspace.com/ground/cground/src/branch/master/docs/syntax.md">here</a>.</p>
<preclass="code"><code>ground {<br> set &x 5<br> println $x<br>}</code></pre>