English

Packages and Documentation Comments

Importing a package (📦)

📦 name 🏠 imports a package. The standard library s is imported from the start, even if you don't write it. In this IDE, besides s, you can use files, json, and testtube.

Emojicode
📦 json 🏠

🏁 🍇
  🍺 ⚪️🕊🌸 🔤{"name": "Emoji", "age": 3}🔤❗️ ➡️ value
  ↪️ 🔲 value 🍯🐚⚪️🍆 ➡️ object 🍇
    ↪️ 🐽 object 🔤name🔤❗️ ➡️ name 🍇
      ↪️ 🔲 name 🔡 ➡️ text 🍇
        😀 text❗️
      🍉
    🍉
  🍉
🍉
Output
Emoji

🏠 means “put the imported types into the same namespace as my own file.” If you write a namespace emoji instead of 🏠, the types go into that namespace. You then use a type in that namespace by writing 🔶NamespaceType.

Reading and writing files (📦 files)

In this IDE, files exist in memory only while the program is running.

Emojicode
📦 files 🏠

🏁 🍇
  🍺 📻🐇📄 🔤memo.txt🔤 📇 🔤Hello🔤❗️❗️
  🍺 📇🐇📄 🔤memo.txt🔤❗️ ➡️ data
  😀 🍺 🔡 data❗️❗️
🍉
Output
Hello

Writing tests (📦 testtube)

testtube is a package for writing tests.

Emojicode
📦 testtube 🏠

🐇 🔬 🧪 🍇
  ✒️ ❗️ 🏁 🍇
    ⛔👇 1 ➕ 1 🙌 2 🔤addition🔤❗️
    🔢👇 📐 🔤abc🔤❗️ 3 🔤length🔤❗️
  🍉
🍉

🏁 ➡️ 🔢 🍇
  ↩️ 👔🆕🔬❗️❗️
🍉
Output
2 assertions, 0 failures

Documentation comments (📗, 📘)

Apart from ordinary comments (💭), there are comments for describing types and packages (for 💭, see Hello World).

Syntax Meaning
📗 … 📗 Describes a type or method. It becomes the description of the type or method right after it
📘 … 📘 Describes the whole package
Emojicode
📗 A type that greets people 📗
🐇 👋 🍇
  🆕 🍇🍉
  📗 Takes a name and returns a greeting 📗
  ❗️ 💬 name 🔡 ➡️ 🔡 🍇
    ↩️ 🔤Hello, 🧲name🧲🔤
  🍉
🍉

🏁 🍇
  😀 💬 🆕👋❗️ 🔤Emoji🔤❗️❗️
🍉
Output
Hello, Emoji

Things you cannot use in this IDE

  • 📜 🔤filename🔤 … includes another file. This IDE compiles only one file, so you cannot use it.
  • 🌍 … exports a type outside the package. You use it when you make a package.
  • 📻, 🔗 … connect to functions written in C++ or other languages. You cannot use them in this IDE.