macports_version
Ryan Schmidt
ryandesign at macports.org
Tue May 22 11:12:43 UTC 2018
On May 22, 2018, at 06:11, Clemens Lang wrote:
>>> The cleanest way of defining a global const variable that I’ve come across is
>>> with trace, tying the variable to a write command with an explicit error
>>> message.
>>>
>>> But the Tcl wiki page that I linked to previously notes that "command names are
>>> the natural choice for constants:
>>> • they live in a separate namespace to variables;
>>> • they are rarely redefined, and few commands do so;
>>> • global commands are available everywhere without importing;
>>> • they offer the possibility of byte-code optimization, i.e. inlining (no idea
>>> if this is or could be done).”
>>
>> Yes, I know that variables can be made read-only through a trace. MacPorts base
>> has a feature built around traces called option_proc. So my question is why it
>> wasn't done that way.
>>
>> Clemens, do you remember?
>
> Simple, declaring a variable gives you the option of changing it. Making it a proc
> doesn't. It's about runtime vs. compile time failure if you're trying to do something
> unsupported.
>
> IMHO, using a proc for read-only variables is much cleaner than using a write trace,
> which feels like a hack to me.
>
> Why would you need it to be a variable? Could you not just call the proc instead?
I'm confused by the inconsistency between variables like macosx_version and xcodeversion, and the macports_version proc.
More information about the macports-dev
mailing list