• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
FDsagizi

auto as C++0x

9 posts in this topic

Hi smile.png

what you think about "auto" as c++ C++0x - this is difficult add to script ?

 

 

Exemple:

class SomeClassName
{    
    void DoSome(){}
}    

SomeClassName @Get()
{
    return ...
}

void F()
{
    auto a = Get();
    a.DoSome();
} 
 
Edited by FDsagizi
0

Share this post


Link to post
Share on other sites

Sorry, I'm not sure what you're asking. Personally, I only use auto for unweildly/very long typenames, like std::map<std::string, MyClass>::const_iterator, for example.

 

What's difficult about your code is that it's not clear what Get() returns (from just reading the function F()). If it were perhaps more appropriately named, it would help improve the clarity of your code.

 

Completely ignore this post! I didn't realize this was the AngleCode forum... sorry for being so blind! I thought FDsagizi might be asking what people thought of auto and if it was good to use it in the following code. I realize now that I wasn't even remotely close (and where's GameDev's embarrassed smiley!?).

Edited by Cornstalks
0

Share this post


Link to post
Share on other sites

I think 'auto' is a useful feature in C++, especially when writing template functions, or even macros. 

 

In AngelScript I can see 'auto' being useful for the mixin classes, and as such I have it on my to-do list to study the possibility of implementing it, however its currently very low on my priority.

 

It's not an easy feature to implement. It would reverse the order things are evaluated in the compiler right now, as it is necessary to first determine the type of the expression and only then declare the actual variable. 

0

Share this post


Link to post
Share on other sites

Sorry, I'm not sure what you're asking

We're in the AngelCode sub-forum -- he's asking about adding C++0x-esque auto to AngelScript.

Oh... wow... I'm an idiot. Sorry folks!

0

Share this post


Link to post
Share on other sites

I used to think type inference would be a great addition to AngelScript.

As i used it more and more in C++, i have turned around.

I see two problems with it.

 

1. AngelScript does not have templates or generics. It doesn't have nested classes neither.

It's not possible to create conventional iterators.

Auto is practically useless without long type names to infer.

 

2. Auto is not magic. You still need to determine if it's an handle, reference or value.

This is a great source of confusion, unwanted constructor/destructor calls and bunch of other nasty bugs.

0

Share this post


Link to post
Share on other sites

AngelScript's mixin classes are generics, and auto can definitely come in handy in such cases. Example:

 

mixin class MyGenericImpl
{
   void func()
   {
      auto c = a + b;
      DoSomething(c);
   }
}
 
class A : MyGenericImpl
{
  int a, b;
}
 
class B : MyGenericImpl
{
  float a, b;
}

 

The variable c in the func() method will have the int type in class A, and the float type in class B, as the code for the mixin class is only compiled in the context where it was included.

 

 

In my opinion, auto is not supposed to be used to infer long type names. That should be done with the use of typedefs to declare a shorter alias for the long types. Currently AngelScript only supports creating aliases for primitive types with typedefs, but eventually I'll allow any type to be used in typedefs.

 

The use of auto outside generic code is not something I recommend, for much the same reasons that saejox mentioned. It would make it much harder to know what type is actually acted upon, thus make it more difficult to read the code.

0

Share this post


Link to post
Share on other sites

That's an interesting use of mixins :)

I didn't go beyond code reuse and separating same class in multiple files.

 

I have just read your ideas page.

I thought i should make a list myself. :)

 

1. Function pointers and function objects

2. Template objects with multiple subtypes

3. Inheritance from registered classes. Without this your whole program design changes, it sucks.

4. Closures/Anonymous functions/Lambdas. Functional programming is the best.

5. Builtin array, set and maps. Everyone needs them, why are they addons. They can still be optional, but builtin is a must. If they are builtin i can finally write some AngelScript only programs. I can write a 1000 word essay how important built-in containers are for a language.

6. Static functions. Great for organization.

7. Generic handle. like ref addon but supports all types and can implicitly convert.

8. Varidic functions. Or functions with argument array. void MyFunction(args). Would be easy with #7

9. Type comparison. if( typeof(my_int) == int ). This may even be a switch/select statement. Useless without #8

10. Unsafe keyword. Mark functions and objects to be free of garbage collection. Also warn user of the dangers. Maybe go crazy with pointers.

11. new and delete. Unmanaged memory for all types. ( would be double awesome with unsafe keyword)

12. Stateful functions. With a keyword like 'yield' . Pause execution, resume when called by other later. Script languages are great for stuff like this.

13. Reflection. No not as powerful as js or lua. At least functions like createClass .addMethod("func()") .invoke("func")

 

These are just stuff i like, no need for a feedback. You are likely very busy.

0

Share this post


Link to post
Share on other sites

1. coming. delegates and also the opCall operator (same as C++ operator())

2. coming. though probably only as registered classes

3. I would like to do this, but I really don't see a proper solution for it. 

4. probably one day

5. no. I provide them as add-ons because not everyone has the same needs. The add-ons are as good as built-in, but more flexible as you can easily change them the way you want. The engine core shall provide the necessary hooks for the add-ons to work seemlessly

6. one day

7. add-on

8. one day

9. add-on

10 & 11. maybe. I do have an interest in adding support for pure pointers again, though with an engine property to turn it off where sandboxing is required

12. as much as possible in add-on, but with necessary support from engine

13. add-on with support for incremental compilation in the engine

0

Share this post


Link to post
Share on other sites

I think i can live without built-in containers. Still, i just feel addon's are not the same. VM could do much better job. Compiler time optimization, better memory layout, avoid unnecessary ref counting, weak iterators etc..

Anyway, that's what i think. I can't even write a simple parser. My suggestions are probably worthless :)

 

Delegates and multiple subtypes are going to be revolutionizing.

I will rewrite half my AngelScript code. Can wait :D

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0