Mandelbrot fractal with Pixie on Ubuntu

My friend Adam introduced me to Pixie back in May, and I made a mental note to play with it a little bit. It was Tim's StrangeLoop talk, however, which inspired me to push all my other little meaningless things to one side to check this out.

The Mandelbrot example in the talk was an especially tasty bit of script to play with, and I was about to type it all out from the video when I noticed that Stuart Hinson had beaten me to the punch.

./pixie-vm examples/mandelbrot.pxi

A first run failed with this error:

/tmp/tmp.cpp: In function ‘int main(int, char**)’:
/tmp/tmp.cpp:19:50: error: no matching function for call to ‘DumpValue()’
  PixieChecker::DumpValue(SDL_PIXELFORMAT_RGBA8888); 
                                                  ^
/tmp/tmp.cpp:19:50: note: candidate is:
In file included from /tmp/tmp.cpp:2:0:
/home/opyate/Code/pixie/pixie/PixieChecker.hpp:432:6: note: template void PixieChecker::DumpValue(T)
void DumpValue(T t)
      ^
/home/opyate/Code/pixie/pixie/PixieChecker.hpp:432:6: note:   template argument deduction/substitution failed:
/tmp/tmp.cpp: In substitution of ‘template void PixieChecker::DumpValue(T) [with T = ]’:
/tmp/tmp.cpp:19:50:   required from here
/tmp/tmp.cpp:19:50: error: ‘’ is/uses anonymous type
  PixieChecker::DumpValue(SDL_PIXELFORMAT_RGBA8888); 
                                                  ^
/tmp/tmp.cpp:19:50: error:   trying to instantiate ‘template void PixieChecker::DumpValue(T)’
Error:  in internal function load-file

in internal function load-reader

Compiling: (with-config {:library SDL2, :cxx-flags [`sdl2-config --cflags`], :includes [SDL.h]} (defconst SDL_INIT_EVERYTHING) (defcfn SDL_Init) (defconst SDL_INIT_VIDEO) (defconst SDL_WINDOWPOS_UNDEFINED) (defcfn SDL_CreateWindow) (defcfn SDL_CreateRenderer) (defcfn SDL_CreateTexture) (defconst SDL_PIXELFORMAT_RGBA8888) (defconst SDL_TEXTUREACCESS_STREAMING) (defcfn SDL_UpdateTexture) (defcfn SDL_RenderClear) (defcfn SDL_RenderCopy) (defconst SDL_WINDOW_SHOWN) (defcfn SDL_RenderPresent) (defcfn SDL_LockSurface))
in examples/mandelbrot.pxi at 10:1
(with-config {:library "SDL2"
^
in pixie function with-config

in /home/opyate/Code/pixie/pixie/ffi-infer.pxi at 212:10
        ~(run-infer *config* @*bodies*))))
        ^
in pixie function run-infer

in /home/opyate/Code/pixie/pixie/ffi-infer.pxi at 196:16
        result (read-string (io/run-command cmd-str))
              ^
in internal function read-string

RuntimeException: :pixie.stdlib/EOFWhileReadingException Unexpected EOF while reading

The error

/tmp/tmp.cpp:19:50: error: no matching function for call to ‘DumpValue(<anonymous enum>)’
  PixieChecker::DumpValue(SDL_PIXELFORMAT_RGBA8888); 

can be worked around by ensuring the FFI-infer runs C++ with -std=c++0x, because this more recent spec lifts the limitation of unnamed types being used as template arguments.

Instead, I just installed Clang and set up my alternatives to point to it:

sudo apt-get install clang
sudo update-alternatives --set c++ /usr/bin/clang++

Et voilà!

Mandelbrot with Pixie