On Tue, 2016-01-12 at 21:54 +0000, Afonso wrote:
> My thoughs about Vala
> =====================
>
> I just started coding in Vala, and i found it's a quite fun language
> to learn, very simillar to Java and C#. The integration with GLib and
> GObject is simply amazing, and the possibilty to generate C code is
> also very pleasant.
>
> As `Vala` is still in a development phase, I would like to suggest
> a few features that could help `Vala` reach the next big step.
>
>
> # More functional support
>
> Altough `Vala` has support for closures, it would be good to hava
> even
> more functional power.
>
> For example, `Vala` could ship with a `filter` function that supports
> every Gee Collection, something like:
>
> var books = new TreeSet<Book> ();
> books_from_year = books.filter ( (b) => { return year == 1952; });
Gee collections have .filter, but they return a Gee.Iterator
>
> Other functions could behave the same way, like `map`, `reverse`,
> `folds`, `all`, `any`, `or`, `all`, `takeWhile`, `dropWhile` just to
> mention a few (i know, i know, Vala != Haskell xD).
>
> Also, most closures end with a return statement. It would be a lot
> cleaner if one could skip the `return` statement, for example:
>
> var f = (a) => { a == 2; }; // Instead of { return a == 2; }
>
> It does much more sense in a closure context not to have a return
> statement.
You can do
var f = (a) => a == 2;
> Also with mutliple statements closures, `Vala` could behave
> a little bit like `Ruby`, and automatically infer what does the
> closure returns:
>
> var f = ( a, b ) => {
> a = b - 1;
> if ( a > b )
> "ok"; // return "ok";
> else
> "not ok"; // return "not ok";
> };
>
>
> # More syntatic sugar for print
>
> Whenever `stdout.printf` or `print` are invoked with an object,
> automatically use `to_string ()` method (like `Java`).
> For example, suppose we have the following class definition:
>
> public class Book : Object {
> public string title { get; set; }
> public int year { get; set; }
>
> public string to_string () {
> return "Title: %s, Year: %d".printf(this.title, this.year);
> }
> }
>
> It would be nice if we could simply print an object like this:
>
> void main (string[] args) {
> Book b = new Book ("The Old Man and the Sea", 1952);
> print (b); // <=> print (b.to_string());
>
> /* Output:
> >> Title: The Old Man and the Sea, Year: 1952
> */
> }
>
>
> Automatic array printing for basic types (and objects - using
> `to_string ()` method), like so:
>
> void main (string[] args) {
> string[] authors = { "George Orwell", "John Steinbeck" };
> int[] years = { 1999, 2000, 2001 };
>
> Book b1 = new Book ("The Old Man and the Sea", 1952);
> Book b2 = new Book ("The Pearl", 1973);
>
> Book[] books = { b1, b2 };
>
> print (authors);
> print (years);
> print (books);
>
> /* Output:
> >> ["George Orwell", "John Steinbeck"]
> >> [1999, 2000, 2001]
> >> [Title: The Old Man and the Sea, Year: 1952,
> Title: The Pearl, Year: 1973]
> */
>
> }
Vala will automatically call to_string() in template strings:
print (@"$authors\n$years\n);
>
> Wish you all the best regards
>
> 3º ano, Mestrado Integrado em Engenharia Informática,
> Universidade do Minho
>
> _______________________________________________
> vala-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/vala-list
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list