Getting started

Version 0.7 of the C++ code generator can be downloaded here. It's only available for Linux at the moment, but versions for MacOS and Windows will be released soon. The Java code generator (version 0.6), can be downloaded here. The C# code generator (version 0.5.4) is available in two versions: Windows-only and cross-platform. The cross-platform version requires .NET Core 3.1 or higher.

After you unzip the file, you'll see four directories: bin, stdlib, examples and sublime-text. The first one contains the compiler, the second one the standard library, and the third one a few ready-to-build examples to get you started. To create your own project, just pick one of them and start making changes to it. You can find more information about them in examples/README.txt. If you want a more complex example to play with, the IMDB example described here is available on github, and so is the introductory example.

Each of the code generators produces, when the compilation process is successful, one or more source files in the target language. These files can then be fed directly to a compiler for the corresponding language if your Cell source code includes a Main(..) procedure, or otherwise included in an existing project.

There documentation for the standard library (which is really minimal at the moment) is available here.

The sublime-text directory contains syntax highlighting files for Sublime Text. Just copy them in the ~/.config/sublime-text-3/Packages/User directory on Linux, or its equivalent in other operating systems.

Debugging

There's no debugger for Cell, and debugging is done mainly by tracing the execution of a program with the help of the print statement. Another useful tool is the assert statement. When an assertion fails, the execution of the program is stopped and all the variables in scope are printed to the standard output or to a file, if they are too large. If the program is running in debug mode (more on that in a second) the call stack is also printed, along with the value of all the arguments of all function calls on it. Call stack and values of function arguments are also printed every time the program crashes, for whatever reason (again, this happens only if the program is running in debug mode). Only a small part of this data is actually written to the standard output, with the rest of it being written to a set of files. All the files created by a program crash are created inside the debug subdirectory of the working directory of the process. This subdirectory is not created automatically: you have to create it manually before running the code, otherwise no dump file will be produced.

Sometimes there's no choice but to debug the generated code. The code itself is all but incomprehensible, but the names of variables and functions are the same as in the Cell sources, with the addition of a short suffix that is needed to avoid name clashes. For example a two-argument non-polymorphic function named my_fn(..) in Cell will be named my_fn_F2(..) in the generated code, and a variable named my_var will become my_var_V. How to print the value of a variable containing/pointing to a Cell object is different for each target language, and is described in the following sections.

C++

The C++ code generator (which as already mentioned is only available as a Linux binary at the moment) produces a file named generated.cpp that contains all the generated code. When compiling the project in embedded mode it also produce a second file, generated.h, that contains the declarations of the generated classes you'll be using from your own C++ code.

In order to compile your code in debug mode, and have it print a complete stack trace when an error occurs, you'll have to use the -d option of the compiler: cellc -d <project file> <output directory>.

When debugging the generated code with GDB, you can print the value of any variable containing a Cell object using the command call print(my_var_V), replacing my_var_V with the name of the variable whose content you want to print.

Java

The Java code generator is provided as a jar file, cellc-java.jar. To run it, just type java -jar cellc-java.jar <project file> <output directory>, assuming cellc-java.jar is in the current directory . The compiler will produce a Generated.java file containing the core logic, and a separate file for each of the public classes you'll be interacting with. Their interface is documented in pseudo-Java code in another generated file, interfaces.txt.

In order to compile your code in debug mode, and have it print a complete stack trace when an error occurs, you'll have to use the -d option of the compiler: java -jar cellc-java.jar -d <project file> <output directory>.

If you want to inspect the content of a variable containing a Cell object when debugging the generated code, just print the output of its toString() method.

C#

The C# code generator is provided as a Windows executable (cellc.exe) and also as cross-platform library (cellc-cs.dll). To use the cross-platform version you'll need to install .NET Core 3.1 or higher. The command to run the compiler is cellc.exe <project file> <output directory> on Windows, or dotnet cellc-cs.dll <project file> <output directory> for the cross-platform version. The compiler generates three different source files: generated.cs, runtime.cs and facades.cs. The first one contains the core generated code, the second the runtime libraries and the last one all the facade classes you'll be interacting with in your own C# code. Their interface is documented in pseudo-C# code in another generated file, interfaces.txt.

In order to compile your code in debug mode, and have it print a complete stack trace when an error occurs, you'll have to use the -d option of the compiler: cellc-cs.exe -d <project file> <output directory>.

If you want to inspect the content of a variable containing a Cell object when debugging the generated code, just print the output of its ToString() method.