🎉 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: Properties

Published August 25, 2008
Advertisement
A week long vacation that is more work than relaxation sucks. 5 extra 3-day weekends? Infinitely better. Today is one of those random bonus days. In addition to squishing that one bug (see below) I wanted to get properties working. And lo, they work (at least for the simple case):

public class foo{	private int internalX;	public int x{		get{			return(internalX);		}	        set{        		internalX = value;	        }	}}public static void main(){	local foo bar = new foo;	bar.x = 42;	print bar.x;}


They should follow the standard C# syntax. Getter only works, setter only untested. Property = Property is untested, but I tried to make sure that it'd work nicely. Invoking the getter/setter using the standard syntax currently works (I need to disable it). And as usual, there's probably some corner cases that don't work quite yet (at least as expected).

A property in Tangent isn't much more than a normal method/method group. Just an extra token to signify that they should be sugared into property syntax. Thus they will likely be assignable to delegates that match the syntax, and passed around as methods/groups can. Declaring the property type as a parameter though will require generics, so isn't available at time of writing.

After Disgaea 3, I'll probably aim for .NET imports, but I might look into something I've been meaning to implement, but haven't quite worked out the details:

Tangent allows you to just stick identifiers next to one another. So something like this is kosher:

Ogre1 smash Knight1

Nice and simple. smash is an infix operator that takes actors. But something like this should be fine too:

Ogre1 move towards Knight1

move would be an infix operator for an actor and some intermediary (towards ) or takes towards and returns an intermediary infix operator.

This sort of thing I think will become (or should become) pretty common in Tangent code. Building it though will involve a number of intermediary types which will be tedious to implement. I should be able to mechanically (and anonymously) implement them. The method declaration would then become something like:

public operator void move towards(Actor Subject, Actor Target);
or (if you wanted a more 2nd-person feel)
public void move (Actor Subject) towards (GameObject Target);

The second would mechanically create three methods.

intermediary0 move (Actor);
intermediary1 towards (GameObject);
void intermediary0 intermediary1

(or)

intermediary0 move (Actor);
intermediary1 intermediary0 towards;
void intermediary1 (GameObject);


The second probably being more consistent. Just need to take my time and wrap my head around the syntax and implementation. One of those things that would probably be a lot easier if I had a theory of computation class under my belt...

Ah well. Properties. w00t.
Previous Entry Tangent: Buggery
Next Entry Tangent Tidbits.
0 likes 1 comments

Comments

nolongerhere
I really like that last idea. It would allow you to think about problems in a much more natural way and also make code easier to read. (though, I do also see a possibility of it making code much harder to read)

August 25, 2008 09:49 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement