[comp.lang.functional] The name of the game

JWC@IDA.LiU.SE (Jonas Wallgren) (04/15/90)

What is a functional language?

There are two main properties:
	1: No assignments, no side effects, referential transparency,
           or whatever you call it.
	2: Higher order functions.

BUT: Is property no. 2 just a nice feature or do you regard it as nessecary for
     a language to be called 'functional'? Does any formal definition?

-------------------------------------------------------------------------------
Jonas Wallgren                                 |                 JWC@IDA.LiU.SE
Department of Computer and Information Science |
Linkoping University                           |-------------------------------
SE-581 83  Linkoping                           |
Sweden                                         |(\x.xx)(\x.x):(forall a.(a->a))
-------------------------------------------------------------------------------

news@usc.edu (04/15/90)

In article <1818@majestix.ida.liu.se> JWC@IDA.LiU.SE (Jonas Wallgren) writes:
>  What is a functional language?

>  There are two main properties:
>	   1: No assignments, no side effects, referential transparency,
>	      or whatever you call it.
>	   2: Higher order functions.

Another question or two:   Would a language subset (limit language use
to those parts which conform to these properties) be considered a
functional language?

Also, wouldn't it be more accurate to say "no reassignments"?  or is
there a serious distinction made between function definition and value
assignments??

Perhaps one should make a distinction between the operating system
(where values and functions can be defined) and the functional
language (where everything is all nice and neat)?  Discussions of the
os go to other newsgroups, but a language which is a mix, such as
lisp, apl, or smalltalk should have a 'functional language subset'.

shap@thebeach.wpd.sgi.com (Jonathan Shapiro) (04/15/90)

> Also, wouldn't it be more accurate to say "no reassignments"?  or is
> there a serious distinction made between function definition and value
> assignments??

There is a difference between initializing a variable and reassigning a
variable.  The first creates a cell for a value (at least semantically)
while the second mutates an existing cell to give it a new value.

Initialization is also known as 'binding,' which is probably the more
common term in the context of functional languages.

To give an example from scheme, the following code fragment operates
in a purely functional way:

	(let ((a (+ 1 2)))
          a)

where the next one doesn't:

	(let ((a nil))
          (set! a (+ 1 2))
          a)

For those of you not familiar with scheme per-se, set! is like setq in other
LISP dialects.  The names of all mutating operators are terminated by a '!'
by convention.

> Perhaps one should make a distinction between the operating system
> (where values and functions can be defined) and the functional
> language (where everything is all nice and neat)?

The question of whether a language is 'functional' or not has nothing to do
with the support environment, such as the OS.  Whether a language is functional
is solely determined by the semantics of the language.

If the language provides routines that maintain private state (such as many
operating system routines), an argument can be made that the language is non-
functional.  Strictly speaking, any language that has input or output
primatives is
by definition non-functional, since these primatives logically maintain state.

In practice, such languages are still considered functional by most.

kono@csl.sony.co.jp (Shinji Kono) (04/15/90)

In article <1818@majestix.ida.liu.se>  , JWC@IDA.LiU.SE (Jonas Wallgren)writes 
> 	1: No assignments, no side effects, referential transparency,
>            or whatever you call it.
> 	2: Higher order functions.

How about "Excluding Non-Determinism comming from parallel execution"?
Most Dataflow programming languages are functional, I think.
--------
Shinji Kono 
$B2OLn??<#(J Sony Computer Science Laboratory, Inc.: kono@csl.sony.co.jp

djohnson@ngagi.ucsd.edu (Darin Johnson) (04/15/90)

SML (Standard ML) is often described of as a functional language.
However, SML allows changing values (if the name is suitably declared) -
and hence allows side effects.  Should SML then be considered a
functional language?  If not, what about the fact that SML has lots
of features traditionally associated with functional languages
(pattern matching, etc)?

(Also, SML allows statements to be explicitly executed sequentially,
which although not strictly forbidden for functional languages, makes
putting side effects in functions easier.  Makes putting print statements
for debugging in the code much easier...)

Darin Johnson
djohnson@ucsd.edu