|
|
"Christian Froeschlin" <chr### [at] chrfrde> wrote in message
news:4a40e339$1@news.povray.org...
> ... note that macros can have parameters and do not
> need to use global variables. From a software engineering view that
> would be preferred because it avoids conflicts with other macros
> or variable names you wish to use for something else
I ceratinly agree that in many programming languages, other approaches would
be preferable, but POV-Ray is a bit limited in this respect and the use of
global variables to control macros that require large numbers of controls is
the best approach I've been able to come up with in POV-Ray from a software
engineering perspective.
The main advantage with using variables in this way is that you can specify
just the variables you need, whereas to accommodate all desired permutations
using the 'MacroA, MacroB etc' technique could require thousands of wrapper
macros.
In this instance, to parameterise drawers, doors, door-handles, the cabinet
itself, shelves, kickboards and worktops, each with an average of 6
parameters for dimensions, colors, openness, handedness etc, you could
pretty quickly get up to 40 or 50 settings, which, IMO, becomes difficult
and messy to manage with parameters. OTOH, in this particular case, if the
macro call is always to be written by an external application then I admit
that this could still be viable.
With the object collection it was also discovered that the use of local
variables didn't guarantee you won't get naming collisions, because certain
identifiers always have a global context, whereas adhering to simple naming
standards, for both local and global variables, seem to readily avoid all
those sorts of problems.
Regards,
Chris B.
Post a reply to this message
|
|