Re: [Vala] Volatile keyword in Vala(please answer)

Sorry for late reply.

Volatile vars also needed for:
* atomic thread locking(atomic-int and atomic-pointer)
* static memory buffers
* static id by pointer

As I said earlier, even .Net support it, and it hates low level support.
Therefore Vala should support it.

I would like to hear if you think this feature is necessary in Vala.


Date: Tue, 28 Aug 2012 10:23:17 +0200
From: raster rastersoft com
To: vala-list gnome org
Subject: Re: [Vala] Volatile keyword in Vala(please answer)

Hash: SHA1

It's supposed that a volatile variable can change "magically" (this is,
being modified by another thread, a device driver...), so the compiler
has to take that into account when doing optimizations.

A crude example in C:

    volatile int v=1;
    while(v==1) {

(Let's assume that another thread will change the 'v' variable when
whatever-has-to-occur happens). In this example, the "volatile" is
mandatory because, without it, the C compiler probably will transform
that in something like:

    if (v==1) {
        goto loop

optimizing the loop and doing the comparison one time, only at the
start, because it sees that the variable isn't being modified inside.
But when you add the "volatile", the C compiler will know that the
variable can be changed from other parts of the code, avoiding that
optimization and comparing the value in each loop.

"volatile" is a reserver keyword in C, so implementing it in Vala would
mean little more than adding it directly in the C source when found in
Vala source.

El 28/08/12 09:14, Mikkel Kamstrup Erlandsen escribió:
On 24 August 2012 17:31, Tal Hadad <tal_hd hotmail com> wrote:

Is volatile keyword supported in Vala? Is it planned?
Few sources say it does, but testing showing it's not.

I asked this question a month ago and no one replay.
Does Jörg Biller include this in Vala?

This question is a bit scarce on detail. What do you expect volatile
to do, and why do you need it?

vala-list mailing list
vala-list gnome org

- -- 
Nos leemos
                 RASTER    (Linux user #228804)
raster rastersoft com    

Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


vala-list mailing list
vala-list gnome org


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