Re: What is a functional language? (Was: Re: Functional languages and ... (was: Cryptarithm solver ...))

1999-09-22 Thread Antti-Juhani Kaijanaho

On Wed, Sep 22, 1999 at 04:57:58PM +0100, D. Tweed wrote:
> Firstly let me check that we mean the same thing by _higher order
> functions, namely they are functions which return functions

... or take functions as parameters.  Such as map, foldr, iterate, etc.

-- 
%%% Antti-Juhani Kaijanaho % [EMAIL PROTECTED] % http://www.iki.fi/gaia/ %%%

  ""
 (John Cage)





What is a functional language? (Was: Re: Functional languages and ... (was: Cryptarithm solver ...))

1999-09-22 Thread Antti-Juhani Kaijanaho

On Wed, Sep 22, 1999 at 02:53:03PM +0100, Claus Reinke wrote:
> Functional programming, i.e., programming with functions, is possible in
> languages that do not support all features that have become common in
> many functional languages.
[eg. higher-order functions]

Well then, it appears that I have a mistaken idea of what functional
programming is.  Can you give me, to cure my ignorance, a few examples
of languages (preferably ones that are in use nowadays) that are *not*
functional and the reasons why this is so.  Is C functional, since it
is possible to program with functions in it?

> From the perspective of numerical programmers, you could also ask: Isn't
> compilation of high-level array operations into efficient code a
> necessary part of every useful (FP) language?

I would definitely agree with that question if you didn't refer to FP
in it.  You don't define FP as "useful", do you?

-- 
%%% Antti-Juhani Kaijanaho % [EMAIL PROTECTED] % http://www.iki.fi/gaia/ %%%

  ""
 (John Cage)





Re: What is a functional language? (Was: Re: Functional languages and ... (was: Cryptarithm solver ...))

1999-09-22 Thread D. Tweed

On Wed, 22 Sep 1999, Antti-Juhani Kaijanaho wrote:

> On Wed, Sep 22, 1999 at 02:53:03PM +0100, Claus Reinke wrote:
> > Functional programming, i.e., programming with functions, is possible in
> > languages that do not support all features that have become common in
> > many functional languages.
> [eg. higher-order functions]
> 
> Well then, it appears that I have a mistaken idea of what functional
> programming is.  Can you give me, to cure my ignorance, a few examples
> of languages (preferably ones that are in use nowadays) that are *not*
> functional and the reasons why this is so.  Is C functional, since it
> is possible to program with functions in it?

Firstly let me check that we mean the same thing by _higher order
functions, namely they are functions which return functions. This is
different from the idea that functions are _pure_, namely that the value
returned by a function depends _only_ on its arguments (and not on some
state, as represented by either local `static' variables or global
varables in C). To my understanding, most people would call a language
functional if the natural way of using it leads to a very large percentage
of the computation being done with pure functions, and it's not if it's
natural to use a significant percentage of comptation which involves
state, either locally or globally. (Note that repeated assignment is
clearly stateful, so any language where this is a natural way 
of doing things is not functional) So there's no sharp
dividing line :-S

Haskell is functional, although it has facilities for dealing with
state via monads.
ML is also functional language, even though it has references which allow
it to deal with state.

Emacs-Lisp is not really a functional language because so much of it
involves manipulating state; however it incorporates some of the ideas
from functional programming as it existed in the late seventies.

C is not functional because the most natural way of coding many algorithms
involves using subroutines (misleadingly named functions!) with either
internal state (even if this is only assignment within loops!) or global
state. Neither are Pascal, Modula-x, Oberon, perl,... This is despite the
fact that you could write C/... programs that made sure that the
subroutines were all functions and that you only ever used single
assignment because it's not natural to do it that way.

(In some ways it's like asking `what characterises an alcoholic?': you
need to note that some people who aren't occasionally drink to excess and
that alcoholics can go without a drink for short periods.)

___cheers,_dave__
email: [EMAIL PROTECTED]   "He'd stay up all night inventing an
www.cs.bris.ac.uk/~tweed/pi.htm   alarm clock to ensure he woke early
work tel: (0117) 954-5253 the next morning"-- Terry Pratchett






Re: What is a functional language? (Was: Re: Functional languages and ... (was: Cryptarithm solver ...)) (fwd)

1999-09-22 Thread Ronald J. Legere


On Wed, 22 Sep 1999, Antti-Juhani Kaijanaho wrote:

> On Wed, Sep 22, 1999 at 02:53:03PM +0100, Claus Reinke wrote:
> > Functional programming, i.e., programming with functions, is possible in
> > languages that do not support all features that have become common in
> > many functional languages.
> [eg. higher-order functions]
> 
> Well then, it appears that I have a mistaken idea of what functional
> programming is.  Can you give me, to cure my ignorance, a few examples
> of languages (preferably ones that are in use nowadays) that are *not*
> functional and the reasons why this is so.  Is C functional, since it
> is possible to program with functions in it?
> 

 <* MUNCHED A LOT HERE *>

 Actually, it is my understanding that C can be used as a functional
language. There is even a book out there called "Functional C" that some
day I really want to take a look at. I am not really sure what it is
about :)  Of course, you have to use a lot of discipline I suppose! 
SOrt of like doing oop in Python or Perl requires a lot of discipline :)


CHeers!