🎉 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: Method Tests Part 2

Published March 01, 2009
Advertisement
Not much time for hobby this weekend. I managed to setup some delegates and make sure they work like they're supposed to. The example code, which includes infix delegates and a quick example of the partial application built into the language:

public static 	foo()				=> void{ print "foo.";}public static	bar(string s)			=> void{ print s;}public static	baz(string s, int i)		=> void{ print s i;}public static	phrase(string s) (int i)	=> void{ print s i;}public static	how now brown cow  		=> void{ print "MOO!";}public static	test (int lhs) times (int rhs)	=> int{ return lhs * rhs; }public static	(int lhs) op (int rhs)		=> int{ return lhs * rhs; }public static	(string lhs) * (string rhs)	=> string{ return lhs + rhs; }public static	(string lhs) ++ (string rhs)	=> string{ return lhs + rhs; }public static	(int x) a b			=> int{ return x+5; }public static delegate	voidDel()				=> void;public static delegate  (string lhs) opDel (string rhs)		=> string;public static delegate	what now brown cow			=> void;public static delegate  cowDelegate cow				=> void;public static 	main()=>void{	foo();	bar "moo.";	baz ("bleat.",6);	phrase "bleat." 42;	how now brown cow;	print test 4 times 6;	print 2 op 3;	print "moose:" * " umm. moose.";	print "moose:" ++ " umm. moose.";	//print 5 a b;		// bug #37	voidDel = foo;	voidDel();	opDel = +;	print "moo" opDel "cow";	opDel = ++;	print "bleat" opDel "sheep";	what = how;	what now brown cow;	cowDelegate = how now brown;	cowDelegate cow;	voidDel = ()=>void{ print "llllama."; };	voidDel();}
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