[Implemented] MacroOff

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

[Implemented] MacroOff

Post by Josh »

Code: Select all

  Macro MyNot
    Not
  EndMacro

  .....
  .....
  .....
  
  MacroOff MyNot
when i'm writing a pbi with reusable code, maybe i'm using some macros used only in my pbi-code. using MacroOff at the end of my pbi-code, i can prevent the change of code outside my pbi-code.
sorry for my bad english
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: MacroOff

Post by netmaestro »

If you're producing library code, all your variable names, arrays, lists, maps, macros, proprietary structures, virtually everything that has a name should be called by a name uniquely identifying the library name first, and then finally the childelement name. For example, _nmpbi243_array_1dim_long_areas() or such. This way, there is no possibility that a user of your library will duplicate your nomenclature by coincidence. Also, you can at a glance, three years later, know exactly what you're looking at. Your MacroOff suggestion, while reasonable, only addresses macros. What about everything else? If you follow rigid, granular, thoroughly-planned naming conventions, this idea will never be necessary.

When you're young and the coding world is new, short cryptic names seem cool. But after adding your seventy-fifth library, believe me when I tell you: they're not.
BERESHEIT
jamba
Enthusiast
Enthusiast
Posts: 144
Joined: Fri Jan 15, 2010 2:03 pm
Location: Triad, NC
Contact:

Re: MacroOff

Post by jamba »

i could see the macro off being useful, but with accurate naming conventions it shouldn't be a problem.
When you're young and the coding world is new, short cryptic names seem cool. But after adding your seventy-fifth library, believe me when I tell you: they're not.
too true! :)
-Jon

Fedora user
But I work with Win7
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: MacroOff

Post by Josh »

i know, what i can make with well selected names. i never have problems with names of variables and so on, because i use global variables only if there is no other way.

actually i'm writing a program, witch creates pb-code from typelibs. in this code are many interfaces, which later used by the programmer. since pb 4.5 you have the help for interfaces in the statusbar and i want to give the programmer the maximum of informations about needed parameters. ok, there are many ways to do that, but i don't know the name of the parameter, because the name comes from the typelib. i didn't want to change the name of the parameter, so i thought, i give some informations in the type of the parameter (i.e. AnyParameterName.date) and change this information to a nativ type by macro. the same for example for unsigned longs :wink:

so i have a problem, because i can't say to the programmer, don't use the name 'date' in your code. if i can stop my macro at the end of my pbi-file, there is no problem. i'm not a programmer of compilers, but imho, the compiler has a 'list' of macros and when it see the MacroOff statement, the compiler is deleting the macro from the 'list'. maybe it's not a quantity of work to implement this function.
sorry for my bad english
Post Reply