From: Florian Gross Date: 2004-07-14T07:22:21+09:00 Subject: Re: Functional Ruby (Re: Why I don't use Ruby.) Sean O'Dell wrote: >>>>> You're not supposed to have operators in a functional >>>>> language, like =, *, + and so on, >>>> BTW, an operator is usually nothing more than syntactic sugar >>>> for a function call. >>> No, functional languages are not supposed to have operators. >>> That's why they're called "functional languages"; they work like >>> functions. >> Most of those operators are exactly like functions. = isn't if its >> an assignment operator, but if it is an comparison operator it >> indeed is compatible to the definition of the function. (Just >> because there's a different syntax for applying it doesn't mean >> that it's really different -- in fact in LISP + is just a function >> with a special name without any additional syntactic sugar.) > I know, but I was trying to illustrate how some people seem to get > the rule against assignment operators confused with simple > assignment. You can assign values to variables in a functional > language, you just have to do it through a function call; the > assignment is permitted, however. We're in agreement. I'm not sure we're that rule is coming from -- do you remember any sources for this or could you try to explain why it exists for yourself? I've not seen it before -- I think the only restriction about all this is that assignment is only a way of aliasing functions or results of function calls, but nothing more than a notation. (Which means that it doesn't really give any more power to you than you already had without it.) >>>>> so you can't assign values "a=10" style, but you should be >>>>> able to say set(a, 10). >>>> Where is exactly the difference from a semantic POV ? >>> Functional languages set the variable in a functional way. >> Functional languages don't enforce a specific syntax like >> function(arg1, arg2) etc., but they indeed specify that a function >> should have no side effects which means that the only way it should >> be able to interact with the outside world is by returning values. >> (Lambda calculus is the origin of functional languages and compared >> to computer languages its syntax is indeed very exotic.) > Unless something has changed, functional languages DO have to enforce > a specific syntax; it must be functional (call, parameter). The > precise syntax is up to each language; lisp does it something like > (set a 10) I believe, but another language could do it set(a, 10). > It really doesn't matter. Well, all you need to do is providing a way to define and apply functions and some basic built-in functions to make the language turing-complete. (Unlambda states that only the K- and S-combinators are needed for defining a turing-complete language, but I still don't understand this completely.) I'm not sure if we're saying the same or something different regarding this point. :) >> I hope I was able to add something valuable. > The only real rule about assignment, I believe (been a long time), is > that it must be in a functional form, and operators are not allowed > (can't do a=10). Why? Where's the difference? :) Regards, Florian Gross