02-Loops and if.md
03-Functions and scopes.md
04-Structs.md
05-Imports and namespaces.md
06-Enums and switch.md
07-Debugging.md
08-Macros and preprocessor.md
10-Annotations.md
11-Operator overloading.md
15-Polymorphism.md
16-Maps and arrays.md
17-Constructors and destructors.md
18-Platforms.md
19-Testing.md
20-Type information.md
21-Inline assembly.md
22-Libraries.md
23-Style conventions.md
24-Exceptions.md
25-Bytecode and VM.md
26-Targeting ARM.md
27-Compile time execution.md
28-Compiler functions.md
29-Importing C headers.md
100-Standard libraries.md
101-OpenSSL.md
102-Logger.md
README.md
07-Debugging.md
NOTE: This chapter is incomplete. It barely covers debuggers but does cover debugging by printing data. Perhaps logging and printing should be it's own chapter? Or maybe this chapter (Debugging) should be renamed to Printing/Logging.
Debugging
Compile with debug information like this (-d):
Debugging by printing
Print debugging can be useful if it's difficult to debug using the other options. Perhaps you have networking with multiple processes. Printing information to stdout is useful.
When debugging code by printing, there are two useful modules. One for logging and one for type information (read about type information in a later chapter).
#import "Logger"
#import "Lang" // IMPORTANT: Lang might be renamed to Types or something else!
// log is a useful macro for printing all kinds of things
log("A number: ",232 + 1 * 9, " a float: ", 23.52, " a string: ", "hi", " a char: ", 'Z')
// Under the hood, log is evaluated to multiple calls to std_print.
// std_print is an overloaded function for many types (floats, integers, strings, pointers)
std_print("A number")
std_print(232 + 1*9)
std_print("A float:")
/* std_print(... */
#import "Array"
// But with type information (Lang module), you can print the data
// inside structs. This saves a lot of time.
arr: Array<i32>
log(&arr)
arr.add(6)
arr.add(9)
log(&arr)
// In other languages (C/C++) you would need to write a function for
// each struct you want to print or type out every member that you
// want to print.