Emojicode Documentation 0.8
Guides Language Reference Package Index

The Basics

This chapter reviews the basics of Emojicode.

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.

Numeric Literals

In the example at the very beginning of this chapter you saw ↩️ 0. Numbers are written in Emojicode just as you would do normally:

2018
12

πŸ’­ some numbers with decimal place
10.234
0.738281

However, integers can not only be written in decimal notation as in the example above, but also in hexadecimal notation, with the prefix 0x, like 0x1D and octal notation, with the prefix 0, like 035.

You can use , within numbers as a thousands separator:

344,000,000
12,000
12,421.5291

Number Types

There are only three numeric types in Emojicode:

The numeric literals we have seen above are converted to an appropriate type in accordance with Type Expectations. This means that a literal like 130 will be interpreted as πŸ’― when a πŸ’― is expected. A literal with decimal place will, of course, never be interpreted as πŸ”’ or πŸ’§.

If no type is expected, a literal without decimal place is of type πŸ”’ and literal with is of type πŸ’―.

Booleans

Emojicode has a type to represent Boolean values: πŸ‘Œ. A boolean value can either be true or false. A true value is created using πŸ‘ and a false value is created using πŸ‘Ž.

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.

Hint

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**.

← Previous Next Up: β€œSyntax” β†’
Something not quite right? Improve this page