[xquery-talk] XQuery Style Conventions

Michael Rys mrys at microsoft.com
Fri Oct 28 10:34:48 PDT 2005


I personally prefer to not repeat the for and lets and write:

let $set1 := (3,2,1)
  , $set2 := (1,2,3)
for $x in $set2
  , $y in $set1
return
  $x +$y

Best regards
Michael

> -----Original Message-----
> From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On
Behalf
> Of Martin Probst
> Sent: Friday, October 28, 2005 2:22 AM
> To: talk at xquery.com
> Subject: Re: [xquery-talk] XQuery Style Conventions
> 
> Hi,
> 
> > let $set1 := (3,2,1)
> > let $set2 := (1,2,3)
> > for $x in $set2
> >      for $y in $set1
> >      return
> >          $x + $y
> >
> > As all for and let clauses simply add another variable and are equal
> > is that respect [...]
> 
> that's quite an interesting question. I generally prefer to keep them
on
> one level in smaller queries, but in certain cases one might argue for
> indentation. In this example both the let statements simply bind a
> value, but the for statements iterate. That's the difference.
> 
> So by indenting the for statement, one might express that this is (at
> least conceptually) a n*m operation, iterating the whole cross product
> of the two sets (btw: sets? there are no sets in XQuery ... except if
> you specify "unordered").
> 
> > Personally, I prefer to keep them all at the same level to keep the
> > query compact (and it also fits well with the grammar).
> 
> Well, if you have queries going over hundreds of lines with >10
> different for/let clauses, it is actually very helpful to get at least
a
> guess at which level of loop nesting you are. Otherwise you just have
a
> long sequence of statements on the same indentation level, so the
> indentation doesn't give you any information. I like the style they
> propose.
> 
> Regards,
> Martin
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk



More information about the talk mailing list