[Vala] Some thoughts aloud about improving syntax in Vala.



For the first time in my life I use mailing list.
---------

I dream about the language of the Genie mix with Vala, mostly because I
(and obviously most people I know) don't like indentation.
The syntax of Vala doesn't exactly match the syntax of C# (If that was the
goal at all), some things are missing, and some vice versa (for example
slices from Python) so here's just a set of ideas what would be nice to
improve.

- no semicolons, almost all modern languages got rid of them (Or make them
optional as in js so as not to break backward compatibility)
- Syntax `(1..6)` for enumerations `foreach var a in (1..10)` instead of
`for(...;...;...)`
- The short syntax of a function Declaration from a C# `add(int a,int b) =>
return a+b`
- The code attribute `infix` for function from Kotlin to put the
parentheses, the function takes a single parameter `print "hello"`, it is
also very useful for creating DSL.
- No need to write void and put brackets when declaring functions that dont
take parameters or return values: `init {`\n`Gtk.init db.init ...}`
- Add support of stupid #define from C for at least some
metaprogramming(Nim compiles in C too, and has metaprogramming as in lisp
when vala with supported introspection thanks to GObject Does not have it
at all), I saw this in commits, but it doesn’t seem like you could declare
a function in that define, just designate a variable. Or at least add the
ability to execute patterned strings #784
<https://gitlab.gnome.org/GNOME/vala/issues/784>
- Add support for tuples, it's just structures with constant fields in C
code. ( this
<https://gitlab.gnome.org/GNOME/vala/blob/master/tests/parser/tuple.vala> cannt
be called tuples,  it’s more like syntactic sugar for declaring variables)
Fun fact: vala displays an error when trying to use tuples
`v.vala:2.12-2.20: error: tuples are not supported`
- Allow to specify variables passed to the function through their names
like C# `func(name: "Max", age: 12 )` (IDEA doing that in Language Server)
Vala also displays a related error: `v.vala:6.9-6.11: error: Named
arguments are not supported yet`
- Same for Classes

There was some  discussion
<https://gitlab.gnome.org/GNOME/vala/issues/688> close
to the topic.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]