After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 472740 - Generates correct, but not easy to read code for reference handling
Generates correct, but not easy to read code for reference handling
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.1.x
Other All
: Low enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
: 588123 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-09-02 05:11 UTC by Sebastian Dröge (slomo)
Modified: 2009-09-17 11:30 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Sebastian Dröge (slomo) 2007-09-02 05:11:16 UTC
Hi,
vala does not create code that humans would write for reference handling and is rather hard to read.

For example:
return (__temp0 = 0, (sample == NULL ? NULL : (sample = (g_object_unref (sample), NULL))), __temp0);
(sample == NULL ? NULL : (sample = (g_object_unref (sample), NULL)));

A human would probably write this with if, else, etc.

Every other part of generated code is perfectly readable though, good work :)

Bye

PS: the two example lines are taken from the code generated from the Gtk sample. I wonder why there is an expression after the return, it's never called anyway?
Comment 1 Sebastian Dröge (slomo) 2007-09-02 05:11:26 UTC
This is with vala 0.1.2 btw...
Comment 2 Jürg Billeter 2007-09-08 21:15:45 UTC
Confirming. Readability of the generated code is not our highest priority but we'll try to improve it as far as possible without complicating the code generator code too much.
Comment 3 Michael Trausch 2009-07-22 18:33:37 UTC
*** Bug 588123 has been marked as a duplicate of this bug. ***
Comment 4 Jürg Billeter 2009-09-17 11:30:46 UTC
commit 599bebc78755313cb08e2ab62b2053e0bf69b40a
Author: Jürg Billeter <j@bitron.ch>
Date:   Thu Sep 17 12:09:02 2009 +0200

    Improve readability of reference counting
    
    Fixes bug 472740.