From: Sean O'Dell Date: 2004-07-14T06:52:18+09:00 Subject: Re: Functional Ruby (Re: Why I don't use Ruby.) On Tuesday 13 July 2004 14:37, Florian Gross wrote: > 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. > >>> 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. > I hope I was able to add something valuable. You did, because I didn't realize that what I had said came out to sound as though I were asserting a specific syntax was needed. 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). Sean O'Dell