** pointer to a pointer

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

** pointer to a pointer

Post 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
sorry for my bad english
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: ** pointer to a pointer

Post 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?
Regards,
JamiroKwai
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: ** pointer to a pointer

Post 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).
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: ** pointer to a pointer

Post 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.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: ** pointer to a pointer

Post 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
sorry for my bad english
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: ** pointer to a pointer

Post 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 :-)
Regards,
JamiroKwai
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: ** pointer to a pointer

Post 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.
sorry for my bad english
OrangeJuice
User
User
Posts: 24
Joined: Sat Jul 24, 2010 11:56 am

Re: ** pointer to a pointer

Post 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.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: ** pointer to a pointer

Post by DoubleDutch »

I like the idea of a point to a pointer to a pointer.... using the number of '*'s as a reference...
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply