platform{} statement

Gustaf Neumann neumann at
Sat Jun 4 04:41:59 PDT 2016

Am 04.06.16 um 10:08 schrieb René J. V. Bertin:
>>       if {$len < 1} {
> My code has 2 here, and I think that's reasonable ("platform darwin" on its own
> doesn't make a lot of sense).
The original code used as signature "proc platform {args} ..." and
pulled later the "os" out of $args, whereas the posted one uses "proc 
platform {os args}",
where tcl does this already for you. Hence, the check in the latter case 
has to respect this
to get the same semantics.
> Need to set os and arch before this line:
>>       } elseif {$altcode ne ""} {
yes, the {$len == 1} check needs to be generalized (was wrong in the 
earlier versions as well).
probably along the lines

    set params [[lrange $args 0 end-$consumed]

base, the "foreach" loop on "$params" and the {$len == 1} check as well....

> Purely academic: with the introduction of the consumed variable one can replace
> this with "elseif {$consumed == 3}" ... but if everything is a string in Tcl
> that might actually be a more expensive operation?
in terms of performance, you will not be able to measure the difference 
(here are no
string to binary conversions necessary). However, when e.g. "platform 
.... else {}" is
called, then the variant with "$consumed == 3" will call the uplevel, 
and the version
with "altcode" not. I would argue, the version with {$altcode ne ""} 
expresses the intent clearer.


More information about the macports-dev mailing list