Re: [q-lang-users] Polynomial module.
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-11-03 07:43:31
|
Keith Trenton wrote: > - sieve {X|Xs} = {X|var Y : sieve {Y:Y in Xs,Y mod X<>0}}; > > [1] one advantage wrt. in-ining "var Y : " : only one (1) line of code is required (see above); The other advantage is that the scope of the variable(s) would be restricted just to a single expression instead of the entire rule. > [2] one (possible) disadvantage wrt. in-ining "var Y : " : are we overloading the colon <:> in an ambiguous way? I don't think so. The "var" should disambiguate it. > [a] sieve {X|Xs} = {X|local Y : sieve {Y:Y in Xs,Y mod X<>0}}; We already have the "var" keyword so why not use it? > [b] sieve {X|Xs} = {X|var Y in sieve {Y:Y in Xs,Y mod X<>0}}; "in" doesn't work, it can't be a predefined keyword, because it's declared as a user-defined operator in the standard library. That's why I picked the colon instead. > [d] sieve {X|Xs} = {X|Y| sieve {Y:Y in Xs,Y mod X<>0}}; This looks nice but introduces syntactic ambiguities because | is also used in the list/stream syntax. E.g., consider {X|bla X}. Is that a stream with head X and tail bla X or a single-element stream with a var declaration in it? Cheers, Albert -- 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 |