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.

Thanks
Tal

> Date: Tue, 28 Aug 2012 10:23:17 +0200
> From: [email protected]
> To: [email protected]
> Subject: Re: [Vala] Volatile keyword in Vala(please answer)
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> 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) {
>         sleep(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) {
> loop:
>         sleep(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 <[email protected]> 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?
> >
> > Cheers,
> > Mikkel
> > _______________________________________________
> > vala-list mailing list
> > [email protected]
> > https://mail.gnome.org/mailman/listinfo/vala-list
> >
> 
> - -- 
> Nos leemos
>                  RASTER    (Linux user #228804)
> [email protected]              http://www.rastersoft.com
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAlA8f/QACgkQXEZvyfy1ha/zvgCgloBpJR6MxRMINNMXaL9cgYVM
> mU8AoIV3hGkdvSybTEXiLRKVR3MsBIco
> =spbp
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> 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

Reply via email to