Re: Design Patterns and Functional programming



On Wed, 18 Jul 2007 02:50:37 +0100, Jon Harrop wrote:

Dmitry A. Kazakov wrote:
On Tue, 17 Jul 2007 00:16:45 +0100, Jon Harrop wrote:

L has closures => L is functional

Ada has task types, but it is not a functional language.

Ada is functional, cool. Anyway, it is no problem to add downward closures
in any OOPL. The reason why C++ does not have it is because C didn't have
local functions.

2. The question is not about "functional languages," it is about
"functional programming paradigm." This is a big difference. One can do OO
programming in assembler. This should by no means imply that assembler is
an OOP language.

To me, this is just a question of automation. Does the compiler automate
closures?

What do you mean under automation?

The function is useless so the inference is inconsequential.

Is "useless" a language term? On the language level anything legal is
"useful" and compiles. On the software design level, you cannot say if a
function is useless without knowing its purpose. For my purpose [to
illustrate the point] it is very useful.

Statically typed OOPL solve this
problem by introducing classes with manifested properties instead of
ad-hoc chimeras like Boolean | Rubbish. What do they have in common?

Are they not exactly equivalent?

Not a all. Classes are sets of types as defined by the programmer. It is
always statically determinable if a given type is a member of the class,
because inheritance is manifested. When inheritance is inferred, it quickly
becomes undecidable as my example shows. Therefore as a "paradigm" a
substantial types inference is a non-starter.

The number of alternatives is infinite.

Yes.

This is not statically checkable,

Is the above OCaml not a counter example? The result is a recurrence
relation.

It is not checkable. Consider the function Recurse jumping over 0..9
indirection levels, where this number is chosen from the figures of decimal
representation of Pi. Now it is impossible to say whether

access x n Integer is a member of the class without evaluation of Pi.

q.e.d.

and there is no way to statically ensure that dispatch never fails at
run-time.

What dispatch?

to a member function of the class.

In a dynamically typed language you get "message not understood." This is a
price to pay to be able to have ad-hoc classes. If you have a class Boolean
| Rubbish, the choice is between to allow operation "not" on it and fail at
run-time when the actual is Rubbish or to try to determine if all members
of the class indeed have "not." As the latter is undecidable, here you are.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: NIL is not of type CONS
    ... x y) and (member x y), ... same language as you might have designed. ... NIL is actually three things: a symbol, the empty list, and false. ... CL community is more "pluralistic" than the Scheme community, ...
    (comp.lang.lisp)
  • Tentative offering of a Gmail Group
    ... curiosity, I have formed one called "English Language", ... Any Google Groups member can read the group, ... In a translation of Tolstoy's _Anna Karenina_ (Part Two, ...
    (alt.usage.english)
  • Re: Static Class Constants (VB 2005)
    ... this is a change in the VB.NET language and you will be force to change ... > with a single button, I get the error "Access of shared member, constant ... >>> Inside the class MyClass ... >>> because I didn't see the warning. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: C# vs. C++ Calling the overridden base class members from derived classes.
    ... Especially member functions invoked as part of the class's ... > member function, ... and knew that the language I was using would communicate the ... common to languages where such terms as baseclass and derived class are not ...
    (comp.lang.cpp)

Loading