I like it, and would gladly incorporate it into the script library.
I especially like the fact that you only modified the parser and builder, which I interprets as the fact that you're translating the above syntax to the more explicit syntax that I currently use in AngelScript. This is good because it maintains backwards compatibility and also allows the script writer to fallback on the more explicit syntax when they want to write something that is goes against these automated code generations (for example a get accessor that returns a handle, but a set accessor that receives a reference.
Exactly. The older, 'first-generation' approach created a separate object aspect category, imaginatively titled 'virtual properties'
which sort of worked as an almagation of 'real' properties and actual methods. You could attach getter/setter functions arbitrarily and had a slightly more natural approach to app-side reflection at the cost of pretty extensive internal rewrites and a lot more code duplication than I think was healthy. This does seem like a good approach in the long run (and could actually be made using the infrastructure I did keep; it was actually lifted more or less wholesale) but ultimately I wasn't comfortable making large refactorings without a *very* thorough understanding of why the existing API is structured the way it is. One more thing to add to the roadmap?
I will also mention I made a few changes to how the naming scheme in particular works internally (with some justification, bear with me) along with this-- while both work entirely independently and you're free to swap back to the old style in the official version, it seems to me that prefixing accessors with 'get_' and 'set_' in the new style could be *extremely* confusing when script writers are attempting to resolve syntax errors-- the signature will obviously look a lot like that of a 'real' function which may be confusing when the actual code will look really different. While arguments could be made that things like line and column numbers can be used as a failsafe, I think this actually gives IDEs and occasionally script writers too much credit!
As a result, getters are now named "<propertyname> {getter}" and setters named "<propertyname> {setter}" respectively. This style has a number of advantages-- no coding style interactions, the declarations themselves actually look a lot more like the code they refer to, and lastly 'break' the parser in such a way so as to render them uncallable via traditional script syntax-- you *must* use the property syntax as opposed to freely mixing
set_AGlobalProperty(50)
and
AGlobalProperty = 50
from the example in the OP. The main downside to this is that using app-side reflection to look up functions by declaration/register application-defined system functions becomes slightly more complex-- I'm adding some special-case methods for this since it seems the user probably has all the required contextual information anyway. Simply iterating over all functions requires no changes and works out-of-the-box.
And, as the final touch, do we like
int ConstTestProperty
{
get const
{
return 5;
}
}
or do we prefer
int AlternateConstTestProperty
{
const get
{
return 6;
}
}
I personally much prefer #1 as it feels a lot more like the 'void Foo::Bar() const' you'd see in normal const member functions and is probably easier to implement, but whatever floats everyone's boat.
EDIT: Also, does it make sense for setters to be declared const? I mean, I can think of cases where you might just be modifying a global property (this could be a good way to do static properties, btw) without changing the state of the actual object itself, but I'm weighing if this is considered poor enough form for it to be killed at a syntactic rather than stylistic level.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.