site-www
site-www copied to clipboard
Language tour should clarify relationship between callable classes and functions
In Dart 2 we changed how callable classes work
class WannabeFunction {
call(String a, String b, String c) => '$a $b $c!';
}
typedef void RealFunction(String a, String b, String c);
main() {
var wf = new WannabeFunction();
var out = wf("Hi","there,","gang");
RealFunction rf = wf; // since Dart 2 this means: rf = wf.call
print('$out');
}
This is not mentioned in the language tour and might be confusing.
We used to have the whole article about emulating functions on the site - but it seems to have been deleted?
Yep, I should fix that part of the language tour.
About the emulating functions article... It looks like the latest version is saved here: https://web.archive.org/web/20190402210311/www.dartlang.org/articles/language/emulating-functions
When we did the dart.dev work we removed a bunch of low-readership articles that had no owners and/or source code tests. (Having everything be tested will be important as we switch to non-nullable types.) Also, taking a quick look at the article, I suspect it makes some claims about the design philosophy of Dart that are no longer true.
@mraleph if you think the topics in this article still belong on dart.dev, and you're willing to mark up the article and provide test files for the code, I'd be happy to apply those changes and publish the content (somewhere) on dart.dev.
In case we decide to reinstate the article's content, the discussion/links here might be handy: #600
This work will be handled in https://github.com/dart-lang/site-www/issues/4267. Closing.