Do not use this method to share code across projects. If you have written really fancy code, create a package, which you can easily make available to other people.
The Language Reference & Guide
- Welcome to Emojicode
- Syntax
- The Basics
- Literals
- Variables and Assignment
- Control Flow
- Classes & Value Types
- Overloading
- Operators
- Optionals
- Errors
- Inheritance and Overriding
- Protocols
- Enumerations
- Types and Namespaces
- Types as Values
- Documentation
- Generics
- Callables
- Packages
- Threads
- Safe and Unsafe Code
- Memory Management
- References
- Appendix: The Emojicode Compiler
The Basics
This chapter reviews the basics of Emojicode that occur in mosts programs or are of importance in the following sections of this Language Reference & Guide.
Source Files
Emojicode source files are UTF-8 encoded text documents in accordance with the syntax specified by the grammar in this documentation.
Source code files must have the extension .π
or .emojic
.
The π Block
The π block is an important part of any Emojicode program as it is the part of the program that is executed when it is started.
Hereβs an example of a π block:
π π
π Get things up and running here...
π
The π block can also return an integer which is then used as the exit code:
π β‘οΈ π’ π
π Get things up and running here...
β©οΈ 0 π Return a code here.
π
Comments
We have seen examples of comments in the previous code samples. Comments allow you to include non-executable text in your code.
Comments begin with π and end at the end of the line. For example:
π This comment ends at the end of the line. Exactly here
You can also use another type of comment that spans multiple lines: Multiline comments starts with ππ and ends with ππ and can contain line breaks:
ππ This is a multiline comment. You can even make
line breaks. ππ
So... When to Use Emojis?
Thereβs sometimes confusion when emojis are used. Basically itβs very simple:
All type, method and initializer names are emojis. On the other hand variables cannot include emojis but must be any combination of characters that cannot be confused with numbers.
Including Other Source Code Files
The Emojicode compiler always expects a single file. Nevertheless, you can include other source code files. Simply speaking, this just inserts the code from the included file.
Syntax:
π π€path/to/a/file.emojicπ€
π π€file.emojicπ€
The path is relative to the directory in which the current source document is.