Comments

Overview

Ideally, every programmer tries its best to make their code readable and understandable. However, there might be scenarios in which extra explanation is very welcomed.

In such scenarios, programmers leave comments in their code that the compiler/interpreter will ignore but people reading the code may find useful.

By taking inspiration from C, in Bleach, a programmer is allowed to write two different types of comments inside the code present in a Bleach file (.bch).

Single-Line Comments

In Bleach, a single-line comment starts with two slashes (//), and the comment continues until the end of the line, just like the example below:

// Here you can put some extra information that the person reading your code might find useful.

For comments that extend beyond a single line, you’ll need to include // on each line, like this:

// This is the beginning of what it is going to be a very long comment.
// Instead of making the user go all the way to the end of the line above
// we can divide comments in different lines. However, always needing to use
// // character seems to be very cumbersome.

Remember that comments can also be placed at the end of lines containing code:

let x = 123.45; // It is allowed to put a comment after a line of code.

Multi-Line Comments

Also like C, Bleach has support for multi-line comments.

In Bleach, a multi-line comment has a beginning and also an ending. The beginning is denoted by a /*, while the ending is denoted by a */. Everything that is written between these characters is considered a comment and, therefore, will be ignored by the Bleach Interpreter during runtime.

The example below shows how to use them properly:

/*
This
is
a
multi-line
comment.

Below, we are storing an
approximation of Euler's
constant inside the variable "e".
*/
let e = 2.71;