Thread: Gs3
View Single Post
  #93  
Old 06-17-2013, 01:15 PM
Julien Julien is offline
Registered User
Join Date: Jun 2013
Posts: 8
Julien is on a distinguished road
Quote:
Originally Posted by Gunderak View Post
I still hate the whole object:type thing. Would love it if it was more like Java and C#, object something;
Hello,

By essence, GScript is a scripting language. GScript is more close to JavaScript-like languages, rather than Java or C#.

This type syntax was chose among other language syntaxes, because it is commonly-used to annotate types in ECMAScript-based languages.

For example:

HTML Code:
// ActionScript
function foo(a:int):int {...}

// TypeScript
function foo(a: number): number {...}

// UnityScript
function foo(a : int) : int {...}

// Haxe
function foo(a : Int) : Int {...}
So, when converting from GS2 syntax to GS3 syntax, you just have to add type annotations to the original syntax.

HTML Code:
//#GS2
function foo(a) {...}

//#GS3
function foo(a : int) : int {...}
With a Java or C# syntax, this will require more semantic changes to the language, like removing the "function" keyword.
Also, you lose the ability to easily import scripts from similar languages (ActionScript, JavaScript, UnityScript, TypeScript...).

HTML Code:
// Java or C#.
int foo(int a) {...}
Reply With Quote