We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

SnekObjects

Objects in C?!? No. Way.

However, Sneklang is built in C, and everything in Sneklang is an "object". To be clear, not a class or object-oriented programming object, but a higher-level data structure that holds some metadata about itself. For example, it will store:

  • What type of data it holds (int, float, string, etc.)
  • The size of the data it holds
  • The data itself
  • How many references to itself exist (at least later, when we build our own garbage collector!)

That last point is critical! Because Sneklang is a garbage-collected language, we need to know how many references to an object exist so we can free it when it's no longer needed.

Assignment

Complete the missing definitions in snekobject.h Here's a breakdown of all that this file should define: