Lambda Expressions and Script Parsing — Is this a good design idea?

Not to discourage you, but I think you would get more out of embedding something like Squirrel or Lua into your project and learning to use the API and the language itself. The upside of this is that you'll have good performance without having to think about the implementation Implementing scripting languages (even basic ones) from scratch is quite a task, especially when you haven't done one before.

Not to discourage you, but I think you would get more out of embedding something like Squirrel or Lua into your project and learning to use the API and the language itself. The upside of this is that you'll have good performance without having to think about the implementation. Implementing scripting languages (even basic ones) from scratch is quite a task, especially when you haven't done one before.

1 for Squirrel; It's awesome and fast. Unless the OP wants the experience of giving birth to a new language, I'd say this is the way to go. – LiraNuna Sep 30 '09 at 2:04 Those are both good suggestions (I have some experience with Lua), but the purpose of this exercise is indeed to experience the pain and agony of implementing a scripting language.

I'm hoping that it will be a good thinking exercise. – ZachS Sep 30 '09 at 2:07 Lua is a great scripting language. It's very flexible, fast, lightweight, and easy to use if you know C.

Just look at the list of games written in Lua: en.wikipedia. Org/wiki/Category:Lua-scripted_video_games – Matt Fichman Sep 30 '09 at 2:39 @ZachS yep, only thing is, I've been there before. It was interesting getting the basics going I admit, but ultimately I didn't even get to the bytecode-execution stage which was a bummer.

– Nick Bedford Sep 30 '09 at 2:52 If you are still interested in the guts of embeddable scripting languages, I suggest you have a glance at lua. Org/doc/jucs05.pdf. – Nick Bedford Sep 30 '097 at 3:01.

To be honest: I don't think it's a good idea as you described, but does have potential. This limits you with an 'annoying' burden of C++'s static number of arguments, which is may or may not what you want in your language. Imagine this - you want to represent a function: VM::allFunctions"functionName"(variable1); But that function takes two arguments!

How do we define a dynamic-args function? With "..." - that means stdargs. H and va_list.

Unfortunately, va_list has disadvantages - you have to supply an extra variable that will somehow be of an information to you of how many variables are there, so we change our fictional function call to: VM::allFunctions"functionName"(1, variable1); VM::allFunctions"functionWithtwoArgs"(2, variable1, variable2); That brings you to a new problem - During runtime, there is no way to pass multiple arguments! So we will have to combine those arguments into something that can be defined and used during runtime, let's define it (hypothetically) as typedef std::vector VariableList; And our call is now: VM::allFunctions"functionName"(varList); VM::allFunctions"functionWithtwoArgs"(varList); Now we get into 'scopes' - You cannot 'execute' a function without a scope - especially in embedded scripting languages where you can have several virtual machines (sandboxing, etc...), so we'll have to have a Scope type, and that changes the hypothetical call to: currentVM->allFunctions"functionName_twoArgs". Call(varList, currentVM->currentScope); I could continue on and on, but I think you get the point of my answer - C++ doesn't like dynamic languages, and it would most likely not change to fit it, as it will most likely change the ABI as well.

Hopefully this will take you to the right direction.

You might find value in Greg Rosenblatt's series of articles of at GameDev. Net on creating a scripting engine in C++ ( gamedev.net/reference/articles/article16... ). The approach he takes seems to err on the side of minimalism and thus may be either a close fit or a good source of implementation ideas.

That is a good article, I believe, and some of his ideas were already a part of my mental framework. Just imagine a map of opcodes where the code is the key and the value is a function that takes care of that particular operation. – ZachS Sep 30 '09 at 2:34.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions