StatiC
StatiC (intended pronunciation /'stætisi/, though /stætik/ and /'stætiksi/ are acceptable) is a C-like language which is entirely static. It doesn't allocate or deallocate memory.
Syntax
Originally, the language was a joke language where the entire gimmick was that it was just C except you can't use dynamic allocation. The joke is still similar, but now there are more jokes.
A lot of the syntax is intended to still basically be like C except you can't use malloc() and free(). That said, it doesn't have all of the versatility of C.
Because it's not actually C, you also can't use any standard functions unless you define them yourself, which means you can't use printf() for example.
There are a lot of other things you can't do, all of which involve malloc() and free(). You also can't use pointers.
A lot of this language is hampered by the fact that I don't know C and have never coded in C. Maybe I will end up writing something which isn't valid C code or is very unoptimized. I don't really care.
These are the type keywords in StatiC, which also go in this order in front of the value.
| Keyword | Effect | Notes |
|---|---|---|
| Datatype Keywords | ||
| float | creates a single precision floating point | |
| int | creates a value specified to be **16** bits long, not 32 | "normal" int is "long int" |
| quadruple | creates a quadruple precision floating point | |
| twobit | creates a 2-bit value | |
| void | indicates variable with no value | assignment to these variables in written code is allowed but does nothing e.g. void notAValue = 42; is allowed and doesn't throw an error unless you try to e.g. add to it |
| Datatype Modification Keywords | ||
| long | doubles the length of any datatype can be applied twice to double the length of long twobit, long int, or long void |
short int is the same size as long long twobit - the size of a normal char short twobit is the same size as boolean |
| short | halves the length of any datatype, cannot be applied multiple times | |
| signed | specifies that twobit or int can have a negative value in two's-complement so it goes from -(half of original height) to (half of original height) - 1 | |
| unsigned | specifies that twobit or int can't have a negative value this is just assumed to be true if neither unsigned or signed are mentioned | |
| Storage Class Keywords | ||
| auto | indicates that a variable only exists within local scope, NOT active by default | you have to explicitly declare that a variable is auto before the type if it's important, |
| extern | indicates that a variable exists outside of local scope, NOT active by default | you have to explicitly declare a value is or is not extern before the type if it's important |
| register | indicates that the value is stored on the register | note that unlike normal C, StatiC literally has zero compilers, so this is legitimately a valuable distinction |
| static | indicates a variable which keeps its value across function calls | |
| Changeability Keywords | ||
| const | the value of the variable doesn't change after it's set | |
| volatile | the value of the variable might change according to the hardware | |
So you can define a volatile static unsigned long long twobit SomeValue, but not a static volatile unsigned long long int SomeValue.
You can also define types as a user:
| Keyword | Effect | Notes |
|---|---|---|
| enum | contextually assigns the values from the type before it to specific names, starting from the lowest value of the type before it; |
short twobit enum bool { TRUE, FALSE }; assigns TRUE to 0 and FALSE to 1 and assumes a twobit in size
|
| struct | defines a structure with valid datatypes with different memory locations | |
| typedef | assigns a different name to an existing datatype | for example, typedef short twobit bool; assigns the name "bool" to the value of a short twobit"bool" can then be used like |
| union | defines a structure with valid datatypes which use the same memory location |
There are also control flow keywords.
| Keyword | Effect | Notes |
|---|---|---|
| break | breaks out of innermost loop | not needed to break out of switch statement |
| case | indicates end of previous case in switch statement and beginning of new case | |
| continue | skips statements after it inside a loop | |
| default | indicates the default case in a switch statement | |
| else | indicates the other option in an if-else block | |
| for | indicates a for-loop, a loop with a controlled runtime | |
| goto | jump to a specific label in the code | labels are written like label:
|
| if | indicates that the code in the block will run based on a condition | |
| return | returns a value from a function | |
| switch | initiates a switch case by indicating the value used to switch | |
| while | creates a loop which ends based on a logical condition and can go on forever | the loop's condition can appear at the beginning or end and be checked there, but "while" always appears at the beginning in order to indicate the loop is starting |
For better or worse, all of these are rather similar to C, and you could probably get StatiC to work like a static version of C if you wanted.
Code Examples
Integer
int main() {
int f = 5;
return 0;
}