I was looking at what we have, where we have diverged, etc., and
thought that it might be good to refer to some psuedo language
examples. I think our main difference on predicates is what lens we
are looking through. I believe that I am looking at IF type statements
and you are looking at SWITCH type statements.

An example, forcing the use of IF:

if (debug) {
  //debug stuff
}

if (ok) {
  //ok stuff
} else {
  //not ok stuff
}

if (height > 500) {
  //tall stuff
} else {
  //short stuff
}

if (color == "green"){
  // green stuff
} else if (color == "yellow"){
  //yellow stuff
} else if (color == "red"){
  //red stuff
}


vs. forced use of SWITCH:

debug=(bool)debug;
switch (debug) {
  case true:
  //debug stuff
}

ok=(bool)ok;
switch (ok) {
  case true:
    //ok stuff
    break;
  default:
    //not ok stuff
}

height=height>5;
switch (height) {
  case true:
    //tall stuff
    break;
  default:
    //short stuff
}

switch (color){
  case "green":
    // green stuff
    break;
  case "yellow":
    //yellow stuff
    break;
  color "red":
    //red stuff
    break;
}


If we aren't passing params to predicates, then things are easy.
{.section} is a basic if, and predicates are the case statements that
turn that IF into a SWITCH. Please correct me, but I think this is how
your Python version works, and people would use it like this:

The basic if/else:
{.section ok}
  //ok stuff
{.or}
  //not ok stuff
{.end}

The basic switch:
{.section color}
  {.isGreen?}
    //green stuff
  {.isYellow?}
    //yellow stuff
  {.isRed?}
    //red stuff
  {.end}
{.end}

That assumes that someone writes three color checking routines in all
the native languages. And it is easy to see that isGreen is related to
color. And if all you wanted to do was test for color being green,
then you do this:

basic if based on value:
{.section color}
  {.isGreen?}
    //green stuff
  {.end}
{.end}

and:
{.section back-color}
  {.isGreen?}
    //green stuff
  {.end}
{.end}

See where we diverge is that I am assuming predicates with args and
looking at the IF statement, which I find more common (looking at json-
template.js, there are no switch statements, only if statements, for
example):

{.if color is "green"}
  //green stuff
{.end}

{.if back-color is green}
  //green stuff
{.end}

[Note: my version of the is predicate, which gets its args
uninterpreted as you suggest, decides to let quote marks be optional.]

But my way of switch is not as elegant since color is repeated:
{.if color is "green"}
  //green stuff
{.end}
{.if color is "yellow"}
  //yellow stuff
{.end}
{.if color is "red"}
  //red stuff
{.end}

It could be less redundant this way:
{.section color}
{.if @ is "green"}
  //green stuff
{.end}
{.if @ is "yellow"}
  //yellow stuff
{.end}
{.if @ is "red"}
  //red stuff
{.end}
{.end}

Still, lots of @ and it doesn't look like how you want it to look. So
I put in, though I'm not the biggest fan, that if color is eliminated,
then use @.

{.section color}
{.if is "green"}
  //green stuff
{.end}
{.if is "yellow"}
  //yellow stuff
{.end}
{.if is "red"}
  //red stuff
{.end}
{.end}

I suppose I could add {.case} for this special case and minimize some
{.end}s.

{.section color}
{.case is "green"}
  //green stuff
{.case is "yellow"}
  //yellow stuff
{.case is "red"}
  //red stuff
{.end}

Default would be {.or}


{.section color}
{.case is "green"}
  //green stuff
{.case is "yellow"}
  //yellow stuff
{.case is "red"}
  //red stuff
{.or}
  //all other colors
{.end}

I feel that the if statement needs color in there. It is typical for
anyone with programming background, even a basic one that template
writers might have. And eliminate in the {.case} case. Also meeting
user expectations. In long templates, seeing:

// 140 lines of stuff
{.true?}
 // 40 lines of stuff
{.end}

is meaningless. I'm starting on moving over a whole complex forum
software package, and the templates just aren't simple examples where
the conciseness looks good.

One last thing, in my clone I'm going to remove the ? from predicates.
Since there is always a {.if} or {.case} in front, there isn't much
point in keeping it. I'm not even sure if the 'is' predicate above
should work like this:

{.if color is green?}

or

{.if color is? green}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JSON 
Template" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/json-template?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to