Re: [q-lang-users] New 'where' syntax
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2007-05-25 11:56:46
|
Keith Trenton wrote: > - In Q this definition can now be written as follows: > - clunky ENV VAR1 VAR1 > - where just VAL1 = lookup ENV VAR1, > - just VAL2 = lookup ENV VAR2: <<<<< > > Is that colon ':' following 'VAR2' correct? It doesn't look right, but I know that I have probably missed something along the way... (so I'm asking you nicely for clarification =). Yes it is... Some kind of proper delimiter which terminates the list of lhs qualifiers/guards was needed (both for readability purposes, and to resolve actual ambiguities in the grammar). I first considered ',', but this wasn't possible since ',' also delimits different definitions in a 'where' clause, and ';' looked awful (as if the equation ended prematurely). I think that ':' is a fairly good choice; if properly formatted, it makes the lhs qualifiers stick out like a kind of "case labels", as shown in my revision of Eddie's original 'strip' example in my previous post: strip C S where N = #S-1 if not null S: = strip C $ sub S 0 (N-1) if S!N = C; = strip C $ sub S 1 N if S!0 = C; otherwise: = S; -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |