Saturday, July 29, 2023

📚 Revisiting the "dev" and "prod" meta-programming macros

A sample program:

' This program's promotion level: <<dev """ development""">> <<prod """ production""">>

<<dev """CONST promotion_level$ = "development" """>><<prod """CONST promotion_level$ = "production" """>>

PRINT "This is the " + promotion_level$ + " version of the program."


Normally, when a program is promoted to "production", the menu items in the"development version" section of the Project Menu get disabled because the development and production versions of the code are the exact same.


As soon as we add a dev macro to a program, BAM takes into account that the development and production versions of the program, even though they may look exactly the same before pre-processing, they will be different after pre-processing.  So BAM's "development version" menu items become enabled to allow comparing the program behaviour between BAM when the dev and/or prod macro(s) is/are applied, and when the dev and/or prod macro(s) is/are not applied.

So although the exact same code for development and production...

The development Preprocess Code Viewer:

The production Preprocess Code Viewer:

We can simultaneously run both preprocessor versions of the code, and program exports can also be done for both preprocessor versions.

The sample code above is particularly useful when exporting programs and letting folk, maybe testers, know which version of the program they are inspecting (reviewing the source code, or running a program.

Documentation recap, from the dev and prod pages:

dev


Description:

The dev directive tells the BAM preprocessor to only include the contained BASIC statements IF the development version of the program is being run or exported.

This is useful when you want the program to look/behave differently depending on the promotion context.

  • Thanks to  for suggesting this kind of ability!

Syntax



prod


Description:

The prod directive tells the BAM preprocessor to only include the contained BASIC statements IF the production version of the program is being run or exported.

This is useful when you want the program to look/behave differently depending on the promotion context.

  • Thanks to  for suggesting this kind of ability!

Syntax















No comments:

Post a Comment

🖥 Flower Tesselation: Testing DRAW and recursive SUB's

This BAM program inspired by Richard Russell's "Flower-like tesselation" BBC BASIC program posted on Facebook . Created in ord...