Re: URI Template experience

On May 19, 2009, at 1:57 AM, Aristotle Pagaltzis wrote:

> I had in mind some further simplifications, though. Mainly, I
> would like the output of expansions to be more invariant so that
> it’s easier to use mixed static and interpolated query strings.
>
> Specifically, I would suggest the same syntax as Roy, but with an
> expansion operator `&` instead of `?`, which never produces a
> leading question mark itself. Then I would declare bare `?`, `&`,
> and `;` (outside of expansions) primary operators (like `{}`),
> whose trivial effect is to output themselves – unless they’d end
> up as the last character in the expanded URI, in which case they
> produce *no* output. (Of course if several such optional
> characters bunch up at the end, they’re *all* dropped.)

I think that violates a very basic principle of templates --
that whatever is outside the delimiters always be interpreted
as static text.  It implies that the delimiter be changed from
one-character that is never allowed in URI to two characters,
the first of which will occur in most URI, changing the algorithm
from zero-lookahead to one-lookahead.  Big -1.

> So a template for a typical query URI would be written something
> like
>
>     /articles?{&tag,per_page,q}
>
> which would just Do The Right Thing. If needs later changed and
> you wanted to include a static parameter, it might become eg.
>
>     /articles?style=summary&{&tag,per_page,q}
>
> and would still DTRT.

But it would not describe the common case in way that is
reversible, and doesn't account for the style=summary being
in an *unordered* query part.

....Roy

Received on Tuesday, 19 May 2009 21:07:03 UTC