POV-Ray : Newsgroups : povray.general : Github repository with useful macros : Re: Github repository with useful macros Server Time
23 Feb 2024 18:59:28 EST (-0500)
  Re: Github repository with useful macros  
From: Tor Olav Kristensen
Date: 19 May 2021 16:00:00
Message: <web.60a56d1f985098ff8e52cc8789db30a9@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
> A comment on local variables.
> Where you have multiple references to a local variable, the symbol
> definition and look up is likely clearer and faster.
> Where you have a local variable with only one reference, however, the
> symbol definition and look up is all overhead. There isn't any
> optimization which removes / streamlines the operations within macros.
> There's a clarity vs performance trade-off in the single reference to
> local variable case.

Thank you for testing this Bill. - And for mentioning this performance issue.

As you say it's a clarity vs performance choice. Normally I prefer to go for
clarity and readability before performance. I also think that we should try to
make it easy for new users to learn from the code in the standard libraries. So
when I made those macros I tried to make it easy to recognize the parts that are

Further I think that descriptive, non cryptic variable names serve as part of
the documentation. (Some seem to think that programming in POV-Ray's SDL is a
continuous short code contest.)

But the macros in question are not so big and complicated, so I have followed
your advice and removed all but one of the local variables that are only
referenced once.

I have also rewritten a few of the macros slightly and added some new ones.

> A millsion calls.


Tor Olav

Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.