|
|
||
Alexander Schunk's BlogJava Closures: Functions or Objects?Posted by alexanderschunk on January 23, 2008 at 11:56 AM | Comments (2)Java Closures? What are they?The question wheather closures are functions or objects came to my mind when reading several proposals concerning on closures. It looks like most authors regard them as both - functions and objects but giving not a real and concrete distinction in what case a closure is a function - or functional object - and an object. For example in Neil Gafters vision for closures, closures seem to be both functions or an anonymous function or method and objects - or even classes beecause its possible to extend a class or template from a closure. I think, if we follow the traditional closure syntax and usage - like in lisp or Perl where closures are regarded as procedures or sub routines. I have difficulties to imagĂne a case where it makes sense or its practical to have the ability to extend a template or class from a closure as follows:
class MyClass
extends
{ int x, int y => int }
or any such nomenclature. If a closure is nothing more than an anonymous function why do we need extend them to real object types? Is it just enough to have a short hand for anonymous methods in which the BGGA Syntax would just be enough? I even have diffiuclty to see what a class or object like:
{int x, int y => int }
in the above example would describe or what power closures provide to describe real world entitities. To me closures are to abstract to describe real world entities i would only allow them as a short hand for anonymous functions or methods as used in Lisp or Perl. Also it would make sense to allow closures as parameters for normal methods i.g:
int myClosureMethod(int x, {int y, int z = > int }){
//something
}
but dont apply them on classes or templates because templates are already a very powerful feature to describe real world entities. Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment
| ||
|
|