Is this safe? [Answered]

Just starting out? Need help? Post your questions and find answers here.
miso
Enthusiast
Enthusiast
Posts: 662
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Is this safe? [Answered]

Post 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...
Last edited by miso on Thu Jan 22, 2026 10:24 pm, edited 1 time in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1558
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Is this safe?

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
miso
Enthusiast
Enthusiast
Posts: 662
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Is this safe?

Post 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.
Little John
Addict
Addict
Posts: 4830
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Is this safe?

Post by Little John »

<removed>
Last edited by Little John on Thu Jan 22, 2026 10:28 pm, edited 1 time in total.
User avatar
STARGÅTE
Addict
Addict
Posts: 2280
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Is this safe?

Post 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.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
miso
Enthusiast
Enthusiast
Posts: 662
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Is this safe?

Post by miso »

Thanks for the clarification.
Post Reply