GNOME Bugzilla – Bug 539703
Allow [Immutable] for function parameters as well
Last modified: 2018-05-22 13:07:28 UTC
If the C API declares a parameter as 'const' for non-immutable objects, there is no way to tell Vala to honor that. Allowing [Immutable] for function parameters should be a good way of telling binding generator to honor that. An example is Gst.TagForeachFunc where the list parameter should be declared as 'const'.
Confirming, makes sense.
*** Bug 567732 has been marked as a duplicate of this bug. ***
Comment from pancake in duplicate bug 567732: Vala needs a way to specify immutable pointers that should be directly mapped into C with the 'const' attribute. It was discussed in the IRC to use the 'immutable' attribute from the Vala side. Here's an example: Vala code: immutable uint8 *ptr; C code: const unsigned char *ptr; Actually gcc show warnings when trying to cast a const pointer to a non-const one. It is harmless, unless you try to write something there...but vala should take care about this kind of access types.
*** Bug 540670 has been marked as a duplicate of this bug. ***
Programmer can think Vala is generating "insecure" code, then should be fixed before 1.0.
Could we reuse the 'const' keyword in this case?
const string TEXT="text" Is translated to #define TEXT "text" Then const can't be used. Immutable can be used later if save immutable variable for multi threading is added to GLib
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/9.