🎉 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!

Plans are useless but planning is essential

Published August 27, 2008
Advertisement
I had a quick ponder earlier today about what all would be necessary in order to write a full Win32 app in Epoch.

Structures are obviously very widely used, so I've been planning on doing them for one of the next releases for quite a while. However, something I overlooked was function callbacks. I'll need to implement a way to tell the Win32 API to call back into Epoch code.

Thankfully, because of the way the Windows message pump system works, I don't have to worry too much about re-entrancy in the VM; but I won't get into the technical details of that for now. Suffice it to say that actually getting a callback and responding to it are fairly trivial.

What's not so simple is handling parameter passing and return values. The callback mechanism will have to properly read the parameters sent in by the caller, and properly return a value back.

Problem is, Epoch runs in a virtual machine at the moment; so there will have to be some kind of marshalling layer that allows the user to define a function signature, define a function matching that signature, and then pass off the function's address for use as a callback.


What I realized, after thinking about this briefly, is that the obvious solution is to implement first-class functions first, because stuff like lambdas and higher order functions will need pretty much the exact same infrastructure as callbacks. Once first-class functions are finished, adding the callback system should be trivial.


So yet again my Epoch roadmap gets discarded, in favor of a totally new one:

  • Release 4 - improved syntax error handling, serialization, tuple and structure support

  • Release 5 - First-class functions

  • Release 6 - callbacks and the Scribble application


(As an aside, it feels great to be able to change the project's scheduling on a whim. Sure beats working under deadlines [grin])


You may wonder, if you are in fact paying attention and not just skimming my journal looking for pretty pictures, what the difference between tuples and structures will be. Both pretty much are an ordered sequence of variable members, right?

Well, there's one minor hangup there - padding. Tuples in Epoch are unpadded, which means that some members might sit on awkward memory boundaries. It also makes tuples unsuitable for direct passing to external APIs, which usually expect padded structures. So a structure is basically equivalent to a tuple except a structure can include padding.

Implementing member padding will undoubtedly be a little sticky, but I should be able to manage.


You may also have noticed (again, presuming that anyone reads this muck) that I've moved structure/tuple support up to R4 instead of R5.

This is because the main goals of R4 were already done (namely, syntax error handling improvement, and serialization) but the release didn't really add much of interest to the language. Plus, it seemed rather wasteful to drop an entire release so soon after R3, over some fairly minor tweakings.

I also got inspired and half-finished tuples last night in a caffiene-fuelled blaze of glory, which is the main reason they got moved up to R4. Heh.



Epoch is already a project I can be proud of, and it's barely got a fraction of the functionality I have planned for it. I'm really looking forward to reaching a point where people can start using the language for real-world app implementations and such.
0 likes 1 comments

Comments

rip-off
You have readers, do not fear. Carry on.
August 27, 2008 06:44 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement