Friday, March 15, 2013

About Dart functions and Closures, Dart funktiot ja sulkemiset

Understanding Closures.. hard.. and Functions. (spec: Functions abstract over executable actions)

This conversation is from:!topic/misc/NOuoGrxW2nE
Direct link to just this piece of conversation.. Great!!

Alex Tatumizer Mar 14 (16 hours ago)


Somehow, I overlooked the fact that whatever is called Function in dart in fact doesn't correspond to javascript notion of Function - it's really a closure, e.g.
Function f="abcd".substring;

This is a great feature, so I withdraw my sarcasm. I thought dart makes distinction between Function (as pointer to function "codes") and Closure, but it probably doesn't.
Won't it be better to call it Closure, not Function then, to avoid confusion?

Ladislav Thon asvered:

Function is just something that can be called. Even this, I believe:

class Answer {
call() => 42;

main() {
var a = new Answer();
print(a is Function);

Some Functions are in fact closures, meaning that they carry their lexical environment, but not all of them. I'm not sure about renaming Function to Closure, I think it would make some situations more clear and some less.

Tatumizer ansvered:

Probably you are right, but then things get a bit confusing indeed for anyone coming from javascript (huge army of potential dart users).
Look at "Tour of the dart language" - they are talking about functions AND closures, without elaborating on subtleties - but this are very important subtleties, deserved to be featured much more prominently.
Needs to be better documented maybe?

Check link for more conversation...

And next theme: Orthogonal Wikipedia:

Computer scienceOrthogonality in programming language design is the ability to use various language features in arbitrary combinations with consistent results.[9] This usage was introduced by von Wijngaarten in the design of Algol 68:

The number of independent primitive concepts has been minimized in order that the language be easy to describe, to learn, and to implement. On the other hand, these concepts have been applied “orthogonally” in order to maximize the expressive power of the language while trying to avoid deleterious superfluities.[10]

Orthogonality is a system design property which guarantees that modifying the technical effect produced by a component of a system neither creates nor propagates side effects to other components of the system. Typically this is achieved through the separation of concerns and encapsulation, and it is essential for feasible and compact designs of complex systems. The emergent behavior of a system consisting of components should be controlled strictly by formal definitions of its logic and not by side effects resulting from poor integration, i.e. nonorthogonal design of modules and interfaces. Orthogonality reduces testing and development time because it is easier to verify designs that neither cause side effects nor depend on them.

An instruction set is said to be orthogonal if it lacks redundancy (i.e. there is only a single instruction that can be used to accomplish a given task)[11] and is designed such that instructions can use any register in any addressing mode. This terminology results from considering an instruction as a vector whose components are the instruction fields. One field identifies the registers to be operated upon, and another specifies the addressing mode. An orthogonal instruction setuniquely encodes all combinations of registers and addressing modes.[citatio

Published originally   in