Tour
Small program
Key things to note from this program are:
voidis a data type that expects no return value.multiplyAndScremis the name of a function, a function is a way to reuse code without having to necessarily type it all again.- Everything with in the
()after the functions name are parameters,a and bare the namesintis the type. varis a way to declare a variable without specifying a type.scremis birb's way of writing to stdout.- Everything on a line after
//is a comment (ignored by the program).
Modifiers
- final - Can't reassign variable
- const - compile time variable (can't reassign)
- static
caution
Static modifiers are still a work in progress
Data Types
Supported data types yet are:
bool- true or false.class- Encapsulates data for an object.double- Birb doubles are 64-bit floating-point numbers as specified in the IEEE 754 standard. 1 bit for the sign, 11 for exponents and 52 for the value itself.enum- Enumerated type, used to define constant valuesint- Basic integer type, 64-bit 2's complement.List- A collection of dynamic objects with a length.Map- Key / Value pairs, key must be a String.Source- source code from an included file.String- Literals (char array), surrounded by either"or's.var- Allows birb to infer the type
Primitive Types example
Class example
What is nest?
Nest is a keyword used to refer to the current instance.
List example
Map example
Variables
Variables in Birb are Explicitly Typed meaning its type must be declared. To define a variable, specify the type, followed by its name and value.
What if I don't want to specify a type
Use var to let birb imply the variables type
Descendant scopes in birb will access the most recent declared variable.
Loops
While loop:
continue is used to jump to the next iteration of a loop, while break is used to stop a loop.
A for loop requires an initialization, condition, and change. Separate them with a semicolon ;.
info
In both cases the braces {} are only required if you are specifying more than one statement.
Control-flow
If statements in Birb work just like they would in other languages. Just as loops, the brackets are optional unless you are specifying more than one statement.
A switch requires the default case, even if it is empty.
Comments
Comments are similar to a majority of other languages;
// For single-line and /* */ for multi-line.
Keywords
| assert | enum | nest | throw |
|---|---|---|---|
| break | follows | new | true |
| case | false | next | var |
| class | final | noSeeb | void |
| const | for | return | while |
| default | grab | static | |
| else | if | switch |