[pmwiki-users] Re: Unifying variables, attributes, properties, part 1

H. Fox haganfox at users.sourceforge.net
Fri Dec 16 04:29:08 CST 2005


On 12/15/05, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Thu, Dec 15, 2005 at 09:25:15AM -0500, Waylan Limberg wrote:
> > So your proposing altering PHP's syntax? No way!!!! Sure, in the wiki
> > markup, that is fine, but wiki markup is not PHP code. I expect PHP
> > code to look like PHP code. Yes, I realized that {$Group} is technecly
> > being passed as a string (so one could say your not altering syntax),
> > but its treated as a variable and IMO should look like one. Wiki
> > markup is wiki marki and PHP code is PHP code. Its not to hard to keep
> > the two seperate in my mind.
>
> It should be pointed out that {$var} is also valid PHP variable
> substitution syntax.  :-)

Complex syntax is useful at times for reducing the number of lines of 
code and/or making code easier to read.

>From the PHP manual:

   "The complex syntax was introduced in PHP 4, and can be
   recognized by the curly braces surrounding the expression.
   [...]
   This isn't called complex because the syntax is complex,
   but because you can include complex expressions this way."

More at http://www.php.net/types.string#language.types.string.parsing.complex

> My motivation is simply to get things that act the same to look
> the same and things that act different to look different.  Thus, if
> one uses {$Group} in wiki markup to get a page's group, then likewise
> we use {$Group} in a format string setting in PHP.  It also makes
> it obvious that global variables aren't directly available in markup.
>
> Ultimately, this would mean that we have only two types of variables
> (instead of the current three):  "page variables" which are
> surrounded with curlies and can be used in either wikimarkup or
> Fmt strings, and "script variables" which don't use curlies and
> are available only in PHP scripts.

I'm not sure if it's is good or bad -- or even worth mentioning -- but
I believe "{$foo}" would be a complex-syntax script variable and and
'{$foo}' or "{\$foo}" would be a page variable in a cookbook script.

Overall, the idea of making it more obvious which variables are page
variables and which ones aren't is appealing.  That distinction was
especially confounding during my early experiences as a skin-author.

Hagan




More information about the pmwiki-users mailing list