The Modeling Language NSLM

In this chapter we describe the NSLM modeling language. NSLM is a high-level programming language designed to support the construction of model architectures in NSL. For efficiency and extensibility reasons, the NSLM language is translated into either C++ or Java, depending on the chosen environment. While NSLM is a self-contained programming language supporting a complete set of types and expressions— the user may take advantage of the full power of C++ and Java when necessary. Yet, we strongly recommend avoiding as much as possible writing "direct" Java or C++ code but try to follow NSLM modeling philosophy and expressions as much as possible. This will result in more consistent and extensible code. In general terms, NSLM is actually a superset of either language in that it provides a set of types and expressions common to both languages together with a library of classes useful in constructing and simulating models in NSL. NSLM syntax has been kept as close as possible to Java with slight variations to simplify the task of building model architecture while at the same time supporting C++ translation as well. Once translated into either Java or C++, an appropriate compiler should process the resulting code (refer to Appendix II for supported compilers). If you are already familiar with either C++ or Java you will find much of the material discussed in this chapter quite familiar, with some aspects such as modules and ports going beyond the semantics provided by either C++ or Java. If you are not familiar with either of the two languages, we recommend getting acquainted with the basic concepts found in object-oriented programming. We recommend reading one of the introductory texts such as The C++ Programming Language by Stroustrup (1997) or Core Java by Cay Horstmann and Gary Cornell (1999), among others.

This chapter is given more as a reference for the NSLM Language than a tutorial. It and the NSLM Methods Appendix I reviews more structures and expressions found in the language. We start by giving an overview of general aspects followed by a description of the different language components.

6.1 Overview

There are a number of general aspects in NSLM that we will overview in this section. General Conventions

We shall be using throughout this chapter a number of general conventions used in NSLM:

Comments are denoted by "/*" at the beginning and "*/" at the end. Single line comments are denoted with "//" at the beginning of the comment. All statements end with a semicolon ";".

We consider object types, object classes or simply classes as equivalent terms (some programming languages distinguish between the concept of class and type). In general, objects represent instances of classes.

We consider module objects as instances of module classes. Similarly, model objects represent instances of model classes. We treat module classes and model classes as special kinds of object classes in the programming language sense, where module objects and model objects become special kinds of objects.

Classes—model classes, module classes and any other object classes—begin their names with an uppercase alphabetic character, e.g. MaxSelectorModel or MaxSelectorStimulus.

Objects—model objects, module objects and objects in general—together with variables and function begin their names with a lowercase alphabetic character, e.g.

maxSelectorModel, maxSelectorStimulus or var.

File names storing NSLM model definitions should have a ".mod" suffix (analogous to ".C" and ".java" suffixes generated by the NSLM compiler translation).


NSLM is a typed-language, similar to C++ and Java, supporting different types of structures. In particular, NSLM supports the following general types:

The primitive or native data type corresponds to the basic types available in most languages, such as C and Pascal, as well as in object-oriented languages such as C++ and Java. These types always start with a lowercase letter and consist of the ubiquitous: int, float, double, char and void (the null type). NSLM adds two more types to this short list: charString and boolean. The charString type translates into "String" in Java and "char*" in C++. The boolean type translates into "boolean" in Java and into an enumerated type in C++ containing 1 (true) and 0 (false). The general object class data type corresponds to the basic types available only in object-oriented languages, such as C++ and Java. As opposed to the limited set of predefined native or primitive types, object types represent an extensible family of classes, either specified by the user or provided by the language in the form of libraries. The classes included in the NSLM class library are an essential component of the system and includes types, such as the scalar NslFloat0 or the input port vector NslDinDouble1, used in describing neural elements, data ports or any other structure.

The module class and model class data types corresponds to the unique family of NSLM types, distinguishing it from other object-oriented languages, such as C++ and Java. While module classes and model classes are object-oriented structures in their nature, they go beyond the basic semantics of an object class. Module classes and model classes incorporate semantics for input and output port based communication, something not found in "regular" object classes.

Was this article helpful?

0 0

Post a comment