zen0wu / topcoder-greed

greedy editor for topcoder arena
Apache License 2.0
229 stars 45 forks source link

Add .Num variable to the Parameter object for templates. #44

Closed vexorian closed 11 years ago

vexorian commented 11 years ago

Sometimes, a custom template may like to have indexes for the parameters. I have two specific use cases:

zen0wu commented 11 years ago

This is actually a good idea, but it's not used right now, in our current template?

wookayin commented 11 years ago

Well, it might be generally useful. However, what do you think about using std::tie( ...params list... ) to extract parameters from the tuple? (just a workaround apart from this feature)

vexorian commented 11 years ago

tuples turned out to be very difficult to work out for other reasons. My initial idea was so that I could use initializer lists to set examples in my template, it turns out tuples don't allow that. tie would work to extract values, that's right. In python though, it worked great because you can uncompress a tuple with *

.Num is still useful for other things like using p0,p1,p2,... in other languages so that a custom template wouldn't need to prefix everything by __ .

zen0wu commented 11 years ago

OK, I guess that makes sense. However, I think a better name for it would be index instead of num, could you please change it? Remember also add this to the wiki ;-)