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

Tangent: this-properties

Published June 30, 2009
Advertisement
Just a little work today. I implemented something mildly weird. For those familiar with C++, Tangent supports a form of operator(). It's something like:

public class foo{    public    this()=>void{        print "foo!";    }}public static    main()=>void{    local foo aFoo = new foo;    aFoo();}


And it's used for the normal sort of functor stuff that C++ uses it for.

What I implemented today was a similar beast for properties:

public class intProperty{    private int x;    public int this{        get{            return(x);        }        set{            x = value;        }    }}public static    main()=>void{   local intProperty x = new intProperty;   x = 5;   print x;}


Not very thrilling. Eventually though, I want to use this mechanism to create stuff like reusable properties that have an event that is triggered when the setter is called. It'll also be used for things often relegated to implicit conversions.

I need to figure out a good way to allow the programmer to disambiguate member access on the property rather than it's value member access, but that's not a huge priority. I don't expect that scenario to arise often.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement