[q-lang-users] Bug? New 'where' syntax
Brought to you by:
agraef
From: Eddie R. <ed...@bm...> - 2007-05-25 18:08:09
|
Albert Graef, >So we already have two thumbs up now, nice. :) Did anyone find any >bugs/flaws/gripes with the syntax yet? I think so, see below. I wonder what John has to say about this? >Ok, I guess it's about time for a first release candidate now. >I'll do that as soon as I've updated the documentation. Did you figure out the bug with specials like ifelse, cond, case, and family running out of stack? Oops, I'll check this when I get a chance! > Right, but note that the similarity is mostly syntactical. Q's 'where' > clauses will still feel unfamiliar to most programmers because: > > (1) those local variables aren't really mutable (although they may be > rebound); > > (2) 'where' clauses are both variable bindings *and* conditions (if a > pattern match fails in a variable binding, the entire equation fails); > > (3) collections of several 'if' and 'where' clauses are processed in a > "backward" fashion, consider e.g.: if X>Y where Y=bla Z where Z=foo X. (3) takes some getting use to. For example: func [] = []; func [L|Ls] where (X1,X2) = Ws where (W|Ws) = L: = [- X1 * X2] ++ func Ls if W > 0; = [0] ++ func Ls if W = 0; = [X1 * X2] ++ func Ls if W < 0; main X= write (func X); ==> main [(25,10,1),(-1,10,3),(0,4,9),(3,8,2)] [-10,30,0,-16]() Trying (2): I know that the "where (X1,X2) = Ws is suppose to fail but is it suppose to do the following? ==> main [(1,2,3,4),(0,3,1,4),(2,6,-1,-2)] /usr/local/bin/q[pid 1802]: caught signal 11 (Segmentation fault), printing backtrace... 14 stack frames /usr/local/bin/q(__qq__print_trace+0x26)[0x804f786] /usr/local/bin/q(__qq__segv_handler+0x7c)[0x804f84c] [0xb7f39420] /usr/local/bin/q(__qq__pushfun+0xa4)[0x8056e94] /usr/local/bin/q[0x805b034] /usr/local/bin/q[0x805cc0a] /usr/local/bin/q[0x805d000] /usr/local/bin/q(__qq__eval+0x4d)[0x805d24d] /usr/local/bin/q(yyparse+0x4b68)[0x8076928] /usr/local/bin/q[0x807805a] /usr/local/bin/q(__qq__parsex+0x24)[0x80781d4] /usr/local/bin/q(main+0x668)[0x8053358] /lib/tls/libc.so.6(__libc_start_main+0xc8)[0xb7cceea8] /usr/local/bin/q[0x804ea91] Eddie |