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



- no semicolons - fully agree. They are meant to act as a delimiter when a
code is composed in-line. In such cases they should be obligatory. But not
in others;
- syntax (1..6) - good idea, however I'd even expand it. I remember your
experiments with quasi-parallel operations in loops. They look more
efficient. Therefore, I'd suggest that the syntax you proposed could
optionally contain another pair of parens with a number of "parallel"
chunks. Like this: (1..6)(2). Of course some additional checks must be then
performed on the loop's body. And caution is advised and be reflected in
docs.
- the short syntax of a function Declaration from a C# - arrow function.
Okay. Why not.
- the code attribute `infix` for function from Kotlin - not sure. Function
should look like function.
- no need to write void and put brackets when declaring functions - not
sure as above. Sometimes readability can be more important than ease of
writing. Besides, it's easier to make mistakes and harder to spot them this
way.
- add support of stupid #define from C - absolutely yes.
- add support for tuples - absolutely yes.
- allow to specify variables passed to the function through their names -
absolutely yes.
- same for classes - absolutely yes.

Would add my proposal:
make sizeof and typeof work with expressions as it's in C, not only type
descriptors.

On Wed, Aug 14, 2019 at 3:04 AM gavr via vala-list <vala-list gnome org>
wrote:

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.
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



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