Gonzalo Chumillas
2016-07-15 17:36:57 UTC
Hi guys,
What do you think about "function overloading"? In the words of Gilad
Bracha, author of Dart:
*There will be no type based overloading in Dart. If you need a different
variant of a method, create a method with a different name. This is what
anyone using a dynmaic language does anyway and they are better for it.
Even in language with mandatory types, type-based overloading is a bad
idea, creating brittleness and ambiguity.*
Source:
https://github.com/dart-lang/sdk/issues/49#issuecomment-108301493
But, what do you think? Is there a case in which "method overloading" is
justified? For example, let's consider the following two methods:
appendHtml(String html) {...}
appendElement(Element element) {...}
The previous code can be simplified by mixing the two functions into a
single one:
append(Object /* String|Element */ source) {
if (!(source is String || source is Element)) {
throw ArgumentError('Source must be String or Element');
}
// etc...
}
Is the previous example a "justified case"?
Thanks so much.
What do you think about "function overloading"? In the words of Gilad
Bracha, author of Dart:
*There will be no type based overloading in Dart. If you need a different
variant of a method, create a method with a different name. This is what
anyone using a dynmaic language does anyway and they are better for it.
Even in language with mandatory types, type-based overloading is a bad
idea, creating brittleness and ambiguity.*
Source:
https://github.com/dart-lang/sdk/issues/49#issuecomment-108301493
But, what do you think? Is there a case in which "method overloading" is
justified? For example, let's consider the following two methods:
appendHtml(String html) {...}
appendElement(Element element) {...}
The previous code can be simplified by mixing the two functions into a
single one:
append(Object /* String|Element */ source) {
if (!(source is String || source is Element)) {
throw ArgumentError('Source must be String or Element');
}
// etc...
}
Is the previous example a "justified case"?
Thanks so much.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.