Timeline for Is it a bad idea to return different data types from a single function in a dynamically typed language?
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 28, 2014 at 16:19 | history | edited | Jörg W Mittag | CC BY-SA 3.0 |
added 632 characters in body
|
Jan 28, 2014 at 16:09 | comment | added | Jörg W Mittag |
In many languages, error conditions are modeled as a subroutine returning either a result type or an error type. Exceptions are a similar idea, except they are also control flow constructs (equal in expressive power to GOTO , actually).
|
|
Jan 28, 2014 at 16:01 | comment | added | gnat | I see. Your point seem to have some merits, but the way it's presented doesn't make it look compelling... rather opposite | |
Jan 28, 2014 at 15:58 | comment | added | Jörg W Mittag |
An exception is one possible result of a method in Java. Actually, I forgot a fourth type: Unit (a method isn't required to return at all). True, you don't actually use the return keyword, but it's a result that comes back from the method nonetheless. With checked exceptions, it is even explicitly mentioned in the type signature.
|
|
Jan 28, 2014 at 15:55 | comment | added | gnat | method in Java returning exception sounds weird. "Return an exception"... hmm | |
Jan 28, 2014 at 15:49 | history | answered | Jörg W Mittag | CC BY-SA 3.0 |