UnDefine array/const/interface/list/struct/var

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

UnDefine array/const/interface/list/struct/var

Post by Flype »

Like in C, it could be useful in some case to 'undef' a variable.

for example, the NOTIFYICONDATA structure is declared in PureBasic but it is the Win95 definition.
If i want to define my own WinXP compatible structure i have to rename it as something like NOTIFYICONDATA_XP.

so, in this case, an UnDefine keyword could be use as this :

Code: Select all

CompilerIf Defined(NOTIFYICONDATA, #PB_Structure) ; Compiler check not really useful
  
  UnDefine NOTIFYICONDATA ; Undefine the Win95 definition
  
  Structure NOTIFYICONDATA ; Updated for WinXP
    cbSize.l
    hwnd.l 
    uId.l 
    uFlags.l 
    uCallbackMessage.l 
    hIcon.l 
    szTip.c[64]
    dwState.l
    dwStateMask.l 
    szInfo.c[256] 
    StructureUnion 
      uTimeout.l 
      uVersion.l 
    EndStructureUnion 
    szInfoTitle.c[64]
    dwInfoFlags.l
    guid.GUID
  EndStructure 
  
CompilerEndIf
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I disagree because I think every structure with the same name should be the same. It's a bit having two local variables with the same name but different types - it becomes messy.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

I think every structure with the same name should be the same
i'm speaking about the possibility to redefine purebasic built-in constants/structs/...
For example, in the MSDN which i often need/read, when a structure is updated it always keep the same name. MS structures are backward compatibles.
it becomes messy.
Yes, but it is powerful ! ;-)
And if you do not call 'Undefine' you can't make side-effect errors.
When it's needed (rarely) it's cool to have.

:roll:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

If the PB version of a structure is not correct or outdated just report it to Fred and I'm sure he'll change it.
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

THat'll take some time and then when Fred releases the next version of PB that takes just another week... I think Flype's idea takes 2 seconds :wink:
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Trond wrote:If the PB version of a structure is not correct or outdated just report it to Fred and I'm sure he'll change it.
yes kindy fred always do. :)

but well it's just an idea, not very important.
that might be useful.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply