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

Initializing array in function call

Started by
3 comments, last by WitchLord 10 years, 4 months ago

Any chance of allowing a initialization list to be used in a function call?


void test(array<string> &in); // Function definition

test({"string1", "string2"});

Or something like:


test(array<string>{"string1", "string2"});

- dave

Advertisement
I'm planning on implementing this. I can't say exactly when it will be ready though.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I'm thinking about attempting to implement this myself. Before I do I'd like to know how you would prefer the syntax to be. I would assume:


func(array<string>{"asd", "asd"});

Any hints or things to keep in mind when working on this?

Thanks,

-dave

I was planning on using the following syntax, though it is not set in stone yet:

// Explicitly give the type of the initialization list
func( array<string> = {"asd", "asd"} );

and eventually

// Implicitly determine the type of initialization list based on what it is used for
func( {"asd", "asd"} );

The latter is much more difficult to implement, and I'll probably hold off on it for a while.

It's quite possible that I implement the first variant already for release 2.28.2 as I'm going to be working on the initialization list implementation anyway. I suggest you wait a little, unless you're impatient and wish to get started immediately :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This has been implemented in revision 1837.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement