Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Re: Re: (tye)Re: Why Closures?

by jdporter (Canon)
on Nov 05, 2002 at 22:19 UTC ( #210591=note: print w/replies, xml ) Need Help??

in reply to Re: Re: (tye)Re: Why Closures?
in thread Why Closures?

IMHO it's better to use the positive definition "FP allows you to treat functions as data" than the negative one "FP is without side effects".
Suit yourself. You'll find yourself in the minority opinion wrt computer scientists.
If you insisted on the negative definition then even most officialy functional languages would not be functional.
Not true, there are some "pure" FP languages. Of course, like most single-paradigm languages, people don't use them very much!

Replies are listed 'Best First'.
Re: Re: Re: Re: (tye)Re: Why Closures?
by Jenda (Abbot) on Nov 06, 2002 at 17:24 UTC

    If you read once more what did I say you'll find out that I DID NOT say there are no pure FP languages. I've spent some time with one (Concurrent Clean) and I DID like it!

    I am not using it now though, noone around here would be able to cooperate with me :-(

    The reason why did I like Clean was not because it restricted me (no side-effects), but because of the restriction it was able to offer something (laziness). Of course the generality of the type system and ability to compose functions at will was appreciated as well.


      Doesn't Haskell play in the purely functional league too?

      Makeshifts last the longest.

        Doesn't Haskell play in the purely functional league too?

        Haskell is the example usually given, but I am told that Haskell has something called monads (don't ask me what they are; I don't have any idea) which allow state to be stored external to the function. Perhaps someone who knows more about Haskell could comment on this. I personally don't think that really keeps it from being a pure functional language, but to explain why I have to step aside and talk about another language...

        The other usual example is Lisp (or a variant, such as Scheme), but I really don't consider Lisp and its kin to be functional per se, though they have stuff in common with functional languages, and if you start throwing around lambda expressions your program can be very functional. But I would say that functions in lisp are just a special kind of list; any given list may or may not be valid as a function, but every function is a list. Lisp is fundamentally list-oriented, then, and functions are just one important kind of list. This makes it possible to program in lisp according to a functional paradigm, but it is also possible to not do that -- for example, to use a procedural paradigm, if one chooses. I have done so in a number of cases. (Just one example: most .emacs files are very procedural in nature.) In that respect, lisp is like Perl: it is a general-purpose language, not tied to one way of doing things.

        Haskell, OTOH, is very much tied to one paradigm, so it could be argued that it is purely functional indeed, because even if these monad thingies give it the ability to store state external to a function, it still is approaching the issue from a functional perspective at some level. I have not seen anyone claim to have used a procedural or object-oriented paradigm when writing in Haskell. If state is stored, it is stored for the benefit of functions, which are the main focus. In lisp (or Perl), I can write a program that consists entirely of one big main routine which does not return any significant value at all. Sure, it calls some builtin functions, but that's also true in C, BASIC, and even assembly language, and nobody is going to call those functional.

        So I think when we decide whether a language is a pure functional language, that may be the question to consider: does it allow for completely abandoning the functional paradigm and writing code entirely another way (e.g., procedural or OO). If it does, the language may have functional bits, but it is not functional per se.

        OTOH, if we apply the analogous criterion to OO, I do not think I know of a single pure object-oriented language. All the OO languages I know about, it is possible to write procedural code if you want. Unless you count data description languages (such as POV or XML), but that's different.

        sub H{$_=shift;while($_){$c=0;while(s/^2//){$c++;}s/^4//;$ v.=(' ','|','_',"\n",'\\','/')[$c]}$v}sub A{$_=shift;while ($_){$d=hex chop;for(1..4){$pl.=($d%2)?4:2;$d>>=1}}$pl}$H= "16f6da116f6db14b4b0906c4f324";print H(A($H)) # -- jonadab

        Yes it does. I looked at that one too. I did not like the monad style IO there though. I find the unique types of Clean easier to understand ... and more natural within a purely functional code.

        The plus of Haskell compared to Clean is that it's open source and that there are more implementations and probably more libraries (it's some time since I played in these parts :(

        Clean seems to be pretty silent :-(


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://210591]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2020-01-25 20:51 GMT
Find Nodes?
    Voting Booth?