Re: [q-lang-users] RFC: Conditional syntax
Brought to you by:
agraef
From: John C. <co...@cc...> - 2006-05-31 14:11:05
|
Albert Graef scripsit: > (Ex. 1) > > abs X = cond ((X<0, -X), (true, X)); > empty Xs = case Xs (([], true), (_, false)); > > Or maybe the sequence of clauses should actually be a stream instead of > a tuple? > > (Ex. 2) > > abs X = cond {(X<0, -X), (true, X)}; > empty Xs = case Xs {([], true), (_, false)}; I actually prefer Ex. 1 to Ex. 2, because there is nothing lazy here. What we have is an immutable sequence (tuple) of possibilities to try. I grant that using a stream makes "cond" and "case" not special forms, but that is an implementation-level consideration, and unless special forms are far more expensive in the interpreter, ought not to be controlling. > This has the advantage that the sequence of clauses could be a > non-special argument (since the expressions inside of it are already > protected by the stream constructor), and that we could even have > infinite lists of clauses. Only if we are capable of making infinite decisions, which I at least am not. > I'm also considering to add some unobtrusive syntactic sugar to allow > "grouping" inside tuples, lists and streams. E.g., [X1,Y1;X2,Y2;...] > would be the same as [(X1,Y1),(X2,Y2),...]; this would also be useful, > e.g., for writing lists of key-value pairs. I agree with this, and I agree that the implied internal objects should be tuples in all cases; again, the situation is inherently immutable and fixed. -- A poetical purist named Cowan [that's me: co...@cc...] Once put the rest of us dowan. [on xml-dev] "Your verse would be sweeter http://www.ccil.org/~cowan If it only had metre And rhymes that didn't force me to frowan." [overpacked line!] --Michael Kay |