deathbeam / spoon

:ramen: Spoon is a programming language that runs blazingly fast, compiles to native code and works everywhere.
https://spoonlang.org
MIT License
56 stars 11 forks source link

Generics syntax #15

Open deathbeam opened 8 years ago

deathbeam commented 8 years ago

Right now, in Raxe we have really ugly syntax for generics. We cannot use classic Haxe <> syntax for generics:

def myArray = Array<String>.new()

because > keyword is also used as do-not-insert-semicolon-at-end-of-line keyword.

Right now, we have this syntax:

def myArray = Array(:String:).new()

which can be sometimes really ugly and misleading. We need better one, but I do not have any idea on how to make better one.

francescoagati commented 8 years ago

In pharen is used ^for types So we can write ^Int ^Array:Int

deathbeam commented 8 years ago

But ^ is also bitwise operator, and in Raxe it is marked as eol operator.

deathbeam commented 8 years ago

Solved, we are using now <> classic syntax. But it probably will have some issues, so I am leaving this open.

kobi2187 commented 8 years ago

because > keyword is also used as do-not-insert-semicolon-at-end-of-line keyword. can you change the > keyword to something else?

deathbeam commented 8 years ago

I am planning to do it, but I still do not know what to use for generics :(

kobi2187 commented 8 years ago

sorry, i'm not familiar with raxe syntax yet. why is there a special marker for end of line? can't \n be enough?

deathbeam commented 8 years ago

It is not special marker. It is just comparison operator, but raxe check for operators at end of lines for multiline statements.

kobi2187 commented 8 years ago

I think it can be done based on the context. for example, if it starts with ### then the whole text will be scanned until finding ### to close it. Afterwards that text will be parsed.