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

Table-like structure #25

Closed deathbeam closed 8 years ago

deathbeam commented 8 years ago

So, I was thinking about emulating table-like declaration for structures, maps and arrays. So for all of them, you will use {}. Example:

def array = { 1, 2, 3 }
# Compiled to: var array = [ 1, 2, 3 ]

def map = { "a" => 1, "b" => 2, "c" => 3 }
# Compiled to: var map = [ "a" => 1, "b" => 2, "c" => 3 ]

def structure = { a:  1, b:  2, c: 3 }
# Compiled to: var structure = { a:  1, b:  2, c: 3 }

What do you think?

escargotprodige commented 8 years ago

For me, everything is ok, except for the arrays, [] syntax is stuck in my head and it would be confusing for me.

deathbeam commented 8 years ago

Yes I know it can be confusing first, but once you will get used to it it can really simplify things.

escargotprodige commented 8 years ago

I agree, and it's not like if it was a big change or something like that. Even some C based languages use that notation

deathbeam commented 8 years ago

Added this notation, example here: https://github.com/nondev/raxe/blob/master/examples/Tables.rx