Re: [q-lang-users] "listof" surprises
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2007-05-17 02:01:47
|
John Cowan wrote: > IMNSHO, rebinding of lexical variables in an inner scope is a bug in > Algol 60 that has leaked into most other programming languages. > It is almost always the result of a programmer error, and instead > of quietly repairing the code with alpha conversion, compilers should > at least warn, and ideally go BZZZT WRONG when they see such a rebinding. Hmm, do you mean that something like \X.(\X.X) X should be an error? I don't think that this is a very good idea because it renders alpha conversion, as it is usually defined, invalid. You might argue that this is just a theoretical issue and we should give in to the practical demands of programmers here. But if you write a program that takes apart and manipulates lambda expressions (as you can do in Q), it's quite tedious if you can't just rename bound variables without keeping track of the entire context. I haven't read the original (1932?) paper on the lambda calculus by Church, but I'm pretty sure that the possibility to rebind variables in inner scopes was in the calculus from the very beginning, predating Algol by some 25 years, so it's certainly not a bug that has "leaked from Algol 60". Rather, I think that Algol picked up some ideas from the lambda calculus there. But I'm not a lambda calculus expert, for me it's just a convenience to quickly write down a "throwaway" function. Maybe someone more versed in the history of the lambda calculus can shed some light on this? Anyway, I agree that shadowed parameters and locals are a big problem in Algol-like languages, but IMHO that's mainly due to a programming style which favours deep nesting of scopes with big chunks of code inside. Alas, lots of Lisp code also looks like this, and to some extent this also applies to Haskell and ML with their nested scoping. But IMHO it's much less of a problem in Q (unless you try really hard to program in an Algol'ish style in Q), since Q pretty much forces you to write lots of little equations without nested scopes. That style also has its problems, of course -- sometimes it's hard not to miss the wood for the trees. ;-) 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 |