Re: [q-lang-users] Speeding up Q
Brought to you by:
agraef
From: Libor S. <li...@gm...> - 2008-04-03 20:51:07
|
On Wed, 02 Apr 2008 13:21:43 +0100, Albert Graef <Dr....@t-...> wrote: > But the biggest difference between all those languages (including Lisp) > and Q/Pure is that the latter are based on general term rewriting rather > than the lambda calculus, which essentially boils down to the simple > feature that there is no distinction between "constructors" and "defined > functions". This is my take on this. Any comments? Functors (identifiers of defined functions), operators, and constructors are essentially one and the same thing. After all, we could define new operators by functions ever since Algol68 and there was equivalence between constructors and functors since Prolog .(A,B) = [A,B]. So I think you are doing the right and natural thing to acknowledge this and to incorporate it onto your language design by essentially removing those unnecessary distinctions from the matcher requirements as well. At least this is how I understand your main point. Now here is a new idea: At the moment, you write (in Q or Pure): square X = X*X; Suppose that we remove the requirement that any functor/operator/constructor be present on the L.H.S. as well? So now we can, whenever we want to, turn this into an anonymous function (lambda expression): X = X*X; by simply omitting the functor (and possibly using -> instead of =). Simply written as any other rule with the = sign, it would become a macro, in this case a dangerously recursive one. However, there is use for ordinary text replacement macros of similar forms. You could then also write this: var Square = (X = X*X); without the lambda and dot syntactical baggage. Square is now a function variable, which can be applied simply as: Square X I like this because it makes very clear and obvious the comparison between the constant function definition square and the variable function definition Square. Notice that they were both initialised with exactly the same expression/value/R.H.S., the only difference being that one is a constant and the other is a variable holding the same value. I know, most of this is just "reinventing" lambda calculus but, at the very least, I think my suggestion could lead to a neater syntax, getting rid of the pesky \ and . which had me puzzled when I first saw them. I had no idea what they were until I was told somewhere deep down the manual, that \ stands for lambda. Libor |