Andy,

It would be nice to get some clarification about the planned behavior of 
pre/post increment/decrement and self-modifying operators (+= -= ...) in TT3.

I think that it makes the most sense for the pre/post increment/decrement 
operators to always return their value - whether in parenthesis or not.

However, I think it makes the most sense for self-modifying operators to 
behave like their expanded counterparts.  If they are inside parenthesis then 
they return their value.  If they are not inside parenthesis then then behave 
like SET operations and don't return anything -- for example a += 1 is 
identical to a = a + 1 and (a += 1) is identical to (a = a + 1).

This is how I made Template::Alloy work and it would be nice to make sure the 
behaviors are consistent.  The following has worked in all versions of 
Template::Alloy:

  use Template::Alloy;

  my $t = Template::Alloy->new;
  $t->process(\<<'EOD') || die $t->error;
  --------
  ++a         | [% ++a %]
  (++b)       | [% (++b) %]
  c += 1      | [% c += 1 %]
  (d += 1)    | [% (d += 1) %]
  e = e + 1   | [% e = e + 1 %]
  (f = f + 1) | [% (f = f + 1) %]
  --------
  EOD

The output for that chunk is:

  --------
  ++a         | 1
  (++b)       | 1
  c += 1      |
  (d += 1)    | 1
  e = e + 1   |
  (f = f + 1) | 1
  --------


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to