Hi guys,

Volatile vars do puzzle me more and more. This is realy complicated
stuff to understand in full detail!

Maybe you can think with me about the expected behavior of the next code:

procedure aabb (volatile byte in aa) is
   aa=aa+1
   print_var(aa) ;point 1
end procedure

var byte a = 7
print_var(a)     ; point 2

'a' is a normal variable, that is passed as 'volatile IN' to the
procedure and is named 'aa'. This does mean that when you use 'aa',
the actual value is fetched at that moment (in contrast with the value
at the time the procedure is called).
However, I modify 'aa' by adding one. What should be printed at 'point
1'? One could argue that this is the actual value of 'a' since 'aa' is
defined volatile. But that would effectivly make 'aa' 'in out' if the
result of the addition is stored into a. And if not, 'aa' is in fact
read-only.
Does this make sense? And what would be the best choice - in-out,
read-only or non-of-the-above?

With 'volatile', 'in' and 'out', one could make 6 combinations. At
this moment, I think only the following make sense*:

- in
- in out
- volatile in out

I'd like to hear your view on this matter.

Joep

* One could argue that 'out' saves a few cpu cycles and a few words of
program code. IMO this is little benefit for the risk to get your
callig variable randomized if it untouched in the procedure...

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to