1

I'm currently designing an esoteric stack-based programming language for code golf (International Phonetic Esoteric Language/IPEL) that, in its current spec, has a stack of values that the user can modify.

However, after trying some simple challenges (and coming from a more procedural and OOP background), I've been considering adding a single register and its associated instructions (stack → reg, reg → stack, etc) for the user to use. (This was in the version -1 language spec, but I decided to axe it in favor of pure stack manipulation.)

What are the pros and cons of having a user-modifiable register in a stack-based language?

bigyihsuan
  • 172
  • 1
  • 9

1 Answers1

1

It seems to me that the primary benefit of a stack-based language is that you don't have to worry about what registers might be used in subroutines, so you don't have to do any saving/restoring or register allocation.

Your single register sounds like it would mess that up.

You probably already have a call/execution stack, a value/parameter stack, and a symbol table. If those really won't do, then adding another value stack would probably be more useful than adding a register. The two stacks and symbol table you already have should really be enough, though.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87
  • 1
    On the old Burroughs stack based mainframes the Register was the top of the stack. The next few places on the stack were Registers 2, 3, 4 up to the total of Registers. Then fast memory and lastly slow memory. That is a very old design though; the machines used Algol-60! – rossum Apr 01 '20 at 18:28