Nim Weekly bio photo

Nim Weekly

News about Nim.

Github

Projects:

Forum:

Core development:

Some Fixes:

symbol lookups fix, defer statement fix, conditional declaration inside a template fix, async http server fix, scopes are still broken for generic instantiation fix, static assign to ref fix, generated unions fix

New features:

times package updated with new functions like getDayOfWeek, countYears

Example code for this week:

An OpenGL example code, it will show a cube in 3d:

nimble install sdl2
nimble install opengl
wget "https://raw.githubusercontent.com/nim-lang/sdl2/master/examples/sdl_opengl_example.nim"
sudo pacman -S sdl2                 # for arch
sudo apt-get install libsdl2-dev    # for debian, maybe the dev is an overkill
nim c -r sdl_opengl_example.nim

Now let’s debug the code, there is a function at line 24 with a newWidth parameter, let’s print that:

nim c --debugger:native sdl_opengl_example
gdb ./sdl_opengl_example
break sdl_opengl_example.nim:25    # setup a breakpoint
run                                # starts the program
bt                                 # prints the call stack
print newwidth                     # prints 640
c                                  # to continue