Jump to content
  • Advertisement
  • entries
  • comments
  • views

Tangent: Generic Method Sneak Peek!

Sign in to follow this  


Had the evening free to work on added implementation of generics. Generic methods are pretty much a hojillion more times difficult to implement than their class brethren. To complicate matters a bit, I'm looking to modify the standard syntax a bit to better support phrases.

There are three things that I'm looking to do with Tangent generic methods that deviates from the norm:

- Generics defined alongside the variable.

This one is kinda straightforward. Instead of public void foo(T x, T y) the declaration will be public void foo( x, y). Should make reading the things a little easier, but it's mostly done to disambiguate the syntax. Multiple declarations of the same name are the same variable (as above).

- Constraints defined alongside the generic identifier

A little less straightforward, but again, hopefully something that's not too weird. This moves the simple type constraints within the angle bracket declaration. Example:

// C#
public void foo() where T:HasName { }

// Tangent
public void foo(){}

I'm not quite sure if I'll go with that syntax or more of the Identifier:Constraint style. Either way, keeping the simple stuff declared alongside the generic itself. Again, declaration closer to the usage should be a little more readable, but the gain is mostly in aiding phrase usage.

- Types as params

Speaking of phrases, I'd like to allow type parameterization in phrases more naturally. print foo to string instead of print foo.ToString() or even print foo to(). This will aid in consistency within the language, allow for more straightforward specializations, and aid in the psuedo DSL programming.

And combined with the way method groups pick specializations it should allow me to construct stuff like is and as or even parameterized constructors within the language itself rather than needing hooks under the hood.

But for now, back to work.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!