🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Epoch Fail (yes, I've been waiting to use that jok

Published August 08, 2008
Advertisement
Well, I finally ran into something major that will have to change in Epoch.

It's kind of a dumb oversight, really, and hopefully it won't be too big of a fix to make; but it's still the first significant thing I'll have to go back and redo in the VM.


At the moment, lexical scopes exist on the heap. This means that every scope always exists, from the moment the program starts to the moment it terminates. Even if you have a lexical scope that is never entered, any variables it allocates will be chewing up memory.

Worse, this means that recursion is impossible. A function has only one instance of its bound scope, regardless of how many times it gets invoked, or what the call chain looks like. Therefore, any program that tries to do recursive calculations will get incorrect results. Each time the function is invoked, it will just overwrite the existing single instance of the scope on the heap, rather than creating a new scope on the stack.


The fix, of course, is to introduce an execution stack to the VM, and have scopes enter and exit correctly on the stack. Technically everything should be stack allocated right now instead of heap allocated, since I have no explicit heap allocation mechanism built into the language yet.

Being naturally lazy, I'm not particularly excited about having to do all this redesign work. Moreover, I'm not entirely sure how to go about it just yet, since it represents a pretty significant overhaul.


Oh well. It was only a matter of time before I ran into some kind of serious mistake; I am technically a language design newbie, after all [grin]
Previous Entry Running Thoughts
0 likes 3 comments

Comments

Telastyn
Stupid recursion. I had to go back and fix that same sort of thing as well.
August 08, 2008 02:27 PM
Daerax
HAHA :p
August 08, 2008 04:24 PM
choffstein
Me three. I was creating a call stack for each function, but when the function was called, ended up overwriting the old values.

Stupid recursion.
August 09, 2008 09:53 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement