Page 1 of 1

Is this safe? [Answered]

Posted: Thu Jan 22, 2026 6:53 pm
by miso

Code: Select all

a+1
*pos+4
a+b-1
offset+1

PeekA(*pos+offset)
Is this safe? I'm always afraid if somehow I will increase something instead of just offsetting...

Re: Is this safe?

Posted: Thu Jan 22, 2026 7:16 pm
by NicTheQuick
What do you mean with safe?
It's basically syntactic sugar for:

Code: Select all

a=a+1
*pos=*pos+4
a=a+b-1
offset=offset+1
But I don't know what you mean with the `PeekA()` line. That's not safe of course because it's an invalid pointer, in this case you are trying to read a byte from address 5.

Re: Is this safe?

Posted: Thu Jan 22, 2026 7:38 pm
by miso

Code: Select all

PeekA(*pos+offset)
Yes I mean exactly that part. My concern: the parameter inside the bracket can not turn to be an addition in any case. Am I right? Sorry if the question is dumb, but I don't know how it is decided if it's an increment or not.

Re: Is this safe?

Posted: Thu Jan 22, 2026 9:52 pm
by Little John
<removed>

Re: Is this safe?

Posted: Thu Jan 22, 2026 10:07 pm
by STARGĂ…TE
miso wrote: Thu Jan 22, 2026 7:38 pm

Code: Select all

PeekA(*pos+offset)
Yes I mean exactly that part. My concern: the parameter inside the bracket can not turn to be an addition in any case. Am I right? Sorry if the question is dumb, but I don't know how it is decided if it's an increment or not.
If you write an expression like:
a + b
the value of a itself is only increased by b, if a is in front of the code line.

So with "function(a+b)" you do not change the value of a itself.
With "c = a + b" you do not change the value of a itself.
Only with "a + b" alone, a is increased by b after its evaluation.

Re: Is this safe?

Posted: Thu Jan 22, 2026 10:23 pm
by miso
Thanks for the clarification.