[87310] trunk/dports/_resources/port1.0/group/php5pear-1.0.tcl
Ryan Schmidt
ryandesign at macports.org
Wed Nov 16 17:49:16 PST 2011
On Nov 16, 2011, at 19:31, Bradley Giesbrecht wrote:
> On Nov 16, 2011, at 5:20 PM, Ryan Schmidt wrote:
>
>> On Nov 16, 2011, at 19:06, Bradley Giesbrecht wrote:
>>
>>> For instance, does a dot in a name have special meaning?
>>
>> Right, you asked me that privately and I forgot to respond. I don't actually know. Conceptually, it creates a namespace; we think of e.g. "php5pear.channel" as belonging to the php5pear namespace. This is to avoid collisions with variables that might be defined in ports or in other portgroups. We have an informal agreement that only the php5pear portgroup would define variables or procedures beginning with "php5pear." But whether the "." in the name has any special significance to the Tcl language I don't know.
>
> Ok, so inside a proc "php5pear.name" and "name" would have no effect on each other?
Right.
> What I have struggled with is the declared "options" before the proc block, "option php5pear.channel", vars declared or passed into the:
> proc php5pear.setup {php5pear.package version {php5pear.channel "pear.php.net"} {php5pear.packagexml "package.xml"}} {
Ah. So here you're definining a procedure called php5pear.setup, and it has a number of arguments. All those arguments are local variables. Not globals or options. But you've given them the same names as your global options. Which is probably confusing things.
Compare with the php5extension portgroup:
[snip]
proc php5extension.setup {extensions version {source ""}} {
global php5extension.build_dirs php5extension.extensions php5extension.ini php5extension.inidir php5extension.source
global destroot
# Use "set" to preserve the list structure.
set php5extension.extensions ${extensions}
php5extension.source ${source}
[snip]
It defines procedure php5extension.setup with some local variables as arguments (extensions, version [1], and optionally source):
proc php5extension.setup {extensions version {source ""}} {
Then inside the proc it lists all the global variables / options it wants to be able to use:
global php5extension.build_dirs php5extension.extensions php5extension.ini php5extension.inidir php5extension.source
Then it sets some of those global variables to the values that were passed into the procedure's arguments, e.g.:
php5extension.source ${source}
[1] Granted, this is also confusing: the second argument of php5extension.setup is assigned to the local variable "version", which is different from the MacPorts global option of the same name. That's why later you see the otherwise odd-looking:
version ${version}
It would be clearer if I used a different local variable name in the proc declaration, one which does not conflict with existing options / globals.
More information about the macports-dev
mailing list