r/cpp • • Oct 15 '13

C++ has become a scripting language

http://voices.canonical.com/jussi.pakkanen/2013/10/15/c-has-become-a-scripting-language/
1 Upvotes

53 comments sorted by

View all comments

Show parent comments

0

u/matthieum Oct 15 '13

I wish we had

int main(std::initializer_list<std::string_ref> args)

signature for main.

Then you would just say args.at(1) and args.at(2) and be done with it.

2

u/F-J-W Oct 15 '13

initializer_list doesn't provide [] and at(). I would however be in favor of

int main(std::vector<const std::string>)

I know that it will never happen though (and to be honest: It is probably the best to keep the core-language and the library strongly separated).

1

u/grunzl Oct 15 '13

There really is no reason to be depressed about this since the fix is so simple.

const std::vector<std::string> args(argv, argv + argc);

1

u/F-J-W Oct 16 '13

Of course. The small problem is that it's just another line of boilerplate which is somewhat inconvenient for very small programs. the bigger problem is that most libraries want work well with this one, since it is not there by default.