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



Hi:

I read your comments, and my opinions are:

- no semicolons, almost all modern languages got rid of them (Or make them
optional as in js so as not to break backward compatibility)

I disagree. In JavaScript there are some cases where they are mandatory in order to avoid ambiguities. Forcing to put them reduces the burden of having to check whether a semicolon is needed or not. And when reading the code, having them also allows to avoid the work of trying to decide if the programmer really wanted to do X, or it is a bug and really wanted to do Y, but there is a missing semicolon.

- Syntax `(1..6)` for enumerations `foreach var a in (1..10)` instead of
`for(...;...;...)`
I like it.
- The short syntax of a function Declaration from a C# `add(int a,int b) =>
return a+b`
Mmm... that already exists for anonymous functions, very useful in callbacks... Or am I getting it wrong?
- 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.
Even python added the parentheses in python3... Removing them could save two keystrokes, but, in my opinion, makes the code harder to read.
- No need to write void and put brackets when declaring functions that dont
take parameters or return values: `init {`\n`Gtk.init db.init ...}`

Again: code harder to read.

- 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>
Yes, I would love that too.
- 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`
Good.
- 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

Like it too.

--
Nos leemos
                         RASTER    (Linux user #228804)
raster rastersoft com              http://www.rastersoft.com



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