RE: uri templates: {?var}

>> Not having to know the state of the URI being built is a very MINOR benefit for the (few) developers of template processor libraries. An {?var} operator that looks for any '?' in that state is a MAJOR benefit to (many many) template authors.

Roy answered:
>It isn't a minor benefit -- it means that each expression can be
expanded in parallel instead of sequentially from left to right,
that the template processor does not need to include a URI parser,
and that each expression can be considered in isolation and thus
not be subject to several factorial more potential test cases.

URIs are too small (a few KB) for anyone to bother to parallelize the expansion.

Expressions cannot quite be considered in isolation as the value of a variable MUST be the same in all expressions that include the variable.

You don't need a URI parser to look for a '?' in a string.


> Because foo{?var1,var2} is the common case and far easier to read.

All the query parameters being variables for the user to provide, and all variable names matching the parameter names is probably the most common case.

Do you really think a parameter with a fixed value, or a parameter name not matching a variable name will be much, much less common? I don't. I think those cases will be quite common so they should be smoothly supported by the template syntax.


HTML forms have a very widely used <input type="hidden"> element, which is strong evidence that authors (of forms or templates) will often want to include fixed parameters. We could assume that protocols using templates will invent their own versions of <input type="hidden">, but it is much simpler to include the fixed parameters directly in the template (and not punishing that choice by making {?var} break in those situations).


--
James Manger

Received on Friday, 15 July 2011 03:15:16 UTC