Skip to content

Comments and docs


Comments in NPL can be single- or multi-line. A single-line comment starts with // and runs through the end of line.

//example of a single-line comment
var a = 5.0; // this is just a value assignment

A multi-line comment surrounds the comment with /* and */. Everything between these comment markers is ignored by the compiler. It is allowed to have a multi-line comment on a single line. Multi-line comments can not be nested.

var a = 5.0; /* This is a valid single-line comment */
/* This too */ var b = 3.14;
/* And this multi-line comment
   will be ignored by the compiler
/* Although it is allowed to embed single-line comments
   in multi-line comments // like this
   It is not allowed
   /* to nest multi-line comments */
Therefore this line will not be recognized as a comment */


NPL supports a subset of JavaDoc, which is a specially crafted multi-line comment immediately preceding the documented entity. The tags it supports are @param and @return.

protocol[p] Example() {
    * The Javadoc starts with '/*‎*'.
    * The description of the element at hand follows. The description can
    * be split to multiple lines for clarity.
    * Also, it may contain multiple paragraphs.
    * After the description comes the tag section. Each tag begins with '@'
    * followed by the tag name. The current items are
    * @param x    describes the function/permission/obligation/protocol parameter x
    * @param y    describes the parameter y. Similarly to above, its description can
    *             be split to multiple lines.
    * @return Description of the return value of a function/permission/obligation.
    *         There may be only one @return tag.
    permission[p] example(x: Number, y: Text) returns Boolean {
        return true;

See the NPL IntelliJ IDEA Plugin for editor support.