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 539703 - Allow [Immutable] for function parameters as well
Allow [Immutable] for function parameters as well
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: general
unspecified
Other All
: Normal blocker
: 1.0
Assigned To: Vala maintainers
Vala maintainers
: 540670 567732 (view as bug list)
Depends on:
Blocks: 578699 582092
 
 
Reported: 2008-06-23 08:28 UTC by Zeeshan Ali
Modified: 2018-05-22 13:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Zeeshan Ali 2008-06-23 08:28:41 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'.
Comment 1 Jürg Billeter 2008-07-30 21:52:07 UTC
Confirming, makes sense.
Comment 2 Jürg Billeter 2009-01-16 16:12:47 UTC
*** Bug 567732 has been marked as a duplicate of this bug. ***
Comment 3 Jürg Billeter 2009-01-16 16:13:38 UTC
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.
Comment 4 Jürg Billeter 2009-07-27 15:39:49 UTC
*** Bug 540670 has been marked as a duplicate of this bug. ***
Comment 5 Daniel Espinosa 2017-02-17 17:14:46 UTC
Programmer can think Vala is generating "insecure" code, then should be fixed before 1.0.
Comment 6 Guillaume Poirier-Morency 2017-02-17 22:36:28 UTC
Could we reuse the 'const' keyword in this case?
Comment 7 Daniel Espinosa 2017-02-18 00:01:47 UTC
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
Comment 8 GNOME Infrastructure Team 2018-05-22 13:07:28 UTC
-- 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.