Forum > General

how works somethink like @identifier^ ?

(1/1)

thierrybo:
Hi,

i am not very used to pointers, and I found a piece of code with this :

@identifier^

For what I understood on pointers, for me

@identifier^ = identifier

I have a variable, I get its address with @ (so now I have a pointer to it), then I dereference this pointer with ^ , so I get the identifier value.

But I have the feeling it it not the case...

Ñuño_Martínez:
It depends on operator precedence. Actually I don't remember the relative precedence for "@" and "^", but anyway I think it's a very bad idea to use "@blablabla^".

Troodon:
@identifier = address = (untyped) pointer. When you append the caret symbol (^) what type of var do you expect to find at that address? What you can do is typecast it: identifier := <expected_type>(@identifier);

I would be curious to know if that code you found works and in what compiler.

thierrybo:
You will find it many times in comobj.pp file from Freepascal winunits-base package.

Navigation

[0] Message Index

Go to full version