Overloading
1
Name:
Anonymous
2011-03-01 20:42
Exhibit A
void some_function(int a = some_default_value)
{
do_something(a);
}
Exhibit B
void some_function()
{
do_something(some_default_value);
}
void some_function(int a)
{
do_something(a);
}
Which do you prefer? (e.g. C# forces the 2nd example)
2
Name:
Anonymous
2011-03-01 20:53
StackOverflow-quality post right here.
3
Name:
Anonymous
2011-03-01 20:58
Obviously default values are more convenient if you are using it for default values. And obviously, overloading allows you to, well, overload on different types, which default values won't in a statically typed language.
I'd prefer a language to support both, though the features do not interact very well. Still, it wouldn't be a problem to let each function use either default values or overloading.
4
Name:
Anonymous
2011-03-01 22:02
ONE WORD THE FORCED OVERLOADING OF FUNCTIONS THAT MIGHT HAVE DEFAULT VALUES THREAD OVER
5
Name:
Anonymous
2011-03-01 22:05
You can do both in C# 4
6
Name:
Anonymous
2011-03-01 22:16
7
Name:
Anonymous
2011-03-02 1:24
>>1
I prefer
fun a=defval -> a.do_something
8
Name:
Anonymous
2011-03-02 1:32
>>1
I prefer
(define (fun (a default)) (do-something a))
9
Name:
Anonymous
2011-03-02 1:52
I prefer Penis
10
Name:
Anonymous
2011-03-02 2:01
I prefer Suntory times.
11
Name:
Anonymous
2011-03-02 2:07
Exhibit A Is obviously superior, because it eliminates duplication of code.
Concision is paramount. Concision and speed. Nothing else matters.
12
Name:
Anonymous
2011-03-02 2:09
ONE WORD: THE FORCED DUPLICATION OF CODE. THREAD OVER
13
Name:
Anonymous
2011-03-02 2:42
>>1
S͔̥̠͉̲̺̖̖͢͜ͅe҉̸͍͙̤͎͖͎̼̟̗̯̩̫̣̩̘̭̙͙̭g͏̴̷̛̭̞̩̖̫͉̮̬̤͔ͅḿ̶̡̻͈̫͎̻̜̭̠͈̤͠ͅe̶̸̸͍͕̙͕̜̝͉͖͎̮̹̫̩͚͇̪̱͞n͘҉̢͎̬̥̫̲̮̗͙̮̥͎̣͚͈̞t̴̶̢̩̼͇̖͍͎̞͚̮͙̖̗̤̯̣̣̰̰̀́a̴̩̮̱͉̤̝̼͈͚̜̬̥̫̩̻̬͟ͅt̨̜͈̯̝̱͕͕͓͍̠̱̼̣͎̘̺̭͞i̸̧̢̯̜̯̝͙͕͕̬̹̥̻͔̗͢͠o̢̱̝̪͕͜͡n̵͓̞̠̮̰̳̩͕͘͟͢ ̛̞̰̬͓̥̥́͢ͅF҉̶̸̡̜̳̣͍͓͈̖̱͖̗̕à̢͈̲͙̙̳̱̹ù̡̫͓̺͓̕ĺ̨̯̮̭̖̹̠̱̠̭̬̺̳͍̼̬̺̤̲̯͟͞͡t̢̙̗͈̝̼̠͓̺͖̦͎͚̟̳̹̥̬́̕͡
14
Name:
Anonymous
2011-03-02 5:58
(a default)
verbosis