constants and functions without arguments

Jerzy Karczmarczuk karczma@info.unicaen.fr
Fri, 30 Mar 2001 16:01:25 +0100


Andreas Leitner wrote at the end of his discussion about
constants/functions sans arguments:


> I mean couldn't one say that there are no constants, just functions
> with no arguments or the Void/Unit argument that return an expression.
> Since we have lazy evaluation, there won't be a problem at runtime,
> but would the type system allow such a thing?



Lennart Augustsson:

> From a pedantic point of view your question makes no sense.  
> The definition of a function is something that takes an argument 
> and transforms it to a result.  So a function always has exactly 
> one argument.  Period.
> 
> But from a practical point of view, yes you can regard constants 
> as functions with no arguments.  And it makes sense from a syntactic 
> point of view:
...

There are different kinds of pedantry.

In Clean there are constants-constants, and constants-functions,
or rather unevaluated graphs, and an assignment

x = expr

may mean something different from

x =: expr

If expr produces a loooong lazy structure, sometimes treating it
as an unevaluated thunk (or not reduced graph) is better than
having the "final" result, although in a pure functional language
there are no differences.

This is another problem, most probably beyond what interests A. L.,
but as you see, people think about such things.



Jerzy Karczmarczuk
Caen, France