Page 1 of 1
** pointer to a pointer
Posted: Wed Jul 28, 2010 9:28 pm
by Josh
in some api's you have a pointer to a pointer. it would be nice, if the pb syntax would accept "**" as prefix to a variable name. the program/compiler shouldn't do anything other, than now. with "**" it would be more clear, that this is a pointer to a pointer.
Code: Select all
Define Test = 4
Define *Test = @Test
Define **Test = @*Test
Re: ** pointer to a pointer
Posted: Wed Jul 28, 2010 10:03 pm
by jamirokwai
Josh wrote:in some api's you have a pointer to a pointer. it would be nice, if the pb syntax would accept "**" as prefix to a variable name. the program/compiler shouldn't do anything other, than now. with "**" it would be more clear, that this is a pointer to a pointer.
Code: Select all
Define Test = 4
Define *Test = @Test
Define **Test = @*Test
Just curious... What is this about? For what could you need this?
Re: ** pointer to a pointer
Posted: Wed Jul 28, 2010 10:15 pm
by Demivec
Josh wrote:in some api's you have a pointer to a pointer. it would be nice, if the pb syntax would accept "**" as prefix to a variable name. the program/compiler shouldn't do anything other, than now. with "**" it would be more clear, that this is a pointer to a pointer.
Code: Select all
Define Test = 4
Define *Test = @Test
Define **Test = @*Test
What would you use to signify a pointer to a pointer to a pointer ... ad infinitum? You would spend all your time counting asterisks trying to figure out what was being pointed at.

As you pointed out the function would be the same, it is just a pointer (to whatever).
Re: ** pointer to a pointer
Posted: Wed Jul 28, 2010 11:44 pm
by Thorium
jamirokwai wrote:
Just curious... What is this about? For what could you need this?
It's used on C for dynamic arrays for example. The array pointer is a pointer to a array of pointers which point to the rows of the array. If i understood it right. I dont used it because it sounds horribly unoptimized.
Re: ** pointer to a pointer
Posted: Thu Jul 29, 2010 12:00 am
by Josh
Demivec wrote:What would you use to signify a pointer to a pointer to a pointer ... ad infinitum?
did i write anything from a pointer to a pointer to a pointer?
maybe you never work with interfaces. there are pointer to a pointer massive used and it would be helpful, if i can sign this variables with "**"
@Thorium
its often used, also without arrays. i.e. look
here
Re: ** pointer to a pointer
Posted: Thu Jul 29, 2010 7:25 am
by jamirokwai
Josh wrote:Demivec wrote:What would you use to signify a pointer to a pointer to a pointer ... ad infinitum?
did i write anything from a pointer to a pointer to a pointer?
maybe you never work with interfaces. there are pointer to a pointer massive used and it would be helpful, if i can sign this variables with "**"
@Thorium
its often used, also without arrays. i.e. look
here
Is it then possible to get the type of a variable or structure?
As I don't code in C or C++, I am not familiar with pointer to pointer things

Re: ** pointer to a pointer
Posted: Thu Jul 29, 2010 11:45 am
by Josh
jamirokwai wrote:Is it then possible to get the type of a variable or structure?
As I don't code in C or C++, I am not familiar with pointer to pointer things

i'm also not coding in c or c++
using "*" says nothing about the type of variable or structure, so, if it would be possible to use "**" this would also say nothing about type or structure. but if i can use
**variablename, i see at the first view, that this is a pointer to a pointer and than i can dereference to
*variablename and then dereference to
variablename.
Re: ** pointer to a pointer
Posted: Thu Jul 29, 2010 3:55 pm
by OrangeJuice
IIRC, pointers to pointers are used on Windows/DirectX to have a concept of dynamic interfaces. E.g. You have a pointer to a function DrawSprite (stupid example) which itself is a pointer in an array of pointers to the real function. When initializing DirectX the init functions set the pointer to either DirectX5 6 or 7 functions, depending on what you asked init to do, what is available and what is compatible.
I might be wrong, it is 7 years since i last did any DirectX programming.
Re: ** pointer to a pointer
Posted: Tue Aug 03, 2010 3:05 pm
by DoubleDutch
I like the idea of a point to a pointer to a pointer.... using the number of '*'s as a reference...