Re: [q-lang-users] where
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-10-10 18:12:11
|
Tim Haynes wrote: > "Rob Hubbard" <hub...@gm...> writes: > >> If you wish to use "let" syntax, then the "let" clause could end in >> "in" rather than a semi-colon: > > Absolutely! It's one of the few ML-isms I still bother remembering - I > always read `let' as `let blah... in' in scheme and haskell. > >> let N = #S - 1 in >> strip C S = strip C $ sub S 0 (N-1) if (S!N = C); Note that the analogy here is purely syntactical. With an ML-style let x = y in z, y may only depend on variables bound in the context of the let expression, not on any variable bound inside z. The more I think about this, the less I like the idea. In lambda calculus based languages like ML, the scope of a local definition never extends across multiple function definitions either. Now in term rewriting the basic unit of definition is not a function definition, but the equation. (Indeed the term rewriting machinery doesn't even have an idea what a "function" is. It just rewrites expressions according to the equations, and function application is just an expression like any other.) So, while I see the utility of this, it's at least questionable whether it fits the basic design of the language. And it doesn't seem to be such a big deal since we already have other means (if-then-else etc.) to accomplish the same. You could even define your own let and letrec special forms in terms of lambda if you really need them. Let would be fairly straightforward, letrec might be a little challenge, though, because it involves fixed points. So where are the lambda hackers who want to take up the challenge? ;-) I think you'll even find some code for "let" in older versions of the former lambda.q module. And a version of the Y combinator which works in Q can be found in the fixpt.q example. 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 |