Adding stacks to Ink

I’ve only really missed one feature in Ink for general narrative development, which is ordered collections. So I added them as a compiler plugin!

LIST qualities =
  strength, skill, control, 
  speed, honour

STACK sensei_values 3 strength

~sensei_values_push(strength)
~sensei_values_push(skill)
~sensei_values_push(honour)

// Oops, sensei had a change of heart
~sensei_values_set(3, speed)

Sensei values {sensei_values_index(1)}, {sensei_values_index(2)}, <>
{sensei_values_index(3)}.

// Outputs: Sensei values strength, skill, and speed.

I understand why Ink doesn’t have complex state management features given how it is used by Inkle, but this still seems like a generally useful enough concept that I thought I’d share. More details in a blog post: Stacks in Ink

4 Likes