On Nov 16, 2011, at 5:49 PM, Ryan Schmidt wrote:

> 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.

Thanks for the explantations. I did use your php5extensions PortGroup as a 
starting point, so I guess you are the root of some of my confusion. I'm so 
kidding :)

So is declaring an "option" something like a shorthand so you don't have to use 
"set" to set or change a var value?

Now I think I know how to accomplish this, where I want to change a var to 
non-default if the Portfile passed in an arg:
option php5pear.channel
option php5pear.packagexml
proc php5pear.setup {package.name package.version {package.channel 
"pear.php.net"} {package.packagexml "package.xml"}}
php5pear.channel                        ${package.channel}
php5pear.packagexml             ${package.packagexml}


Regards,
Bradley Giesbrecht (pixilla)




_______________________________________________
macports-dev mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Reply via email to