April 14, 2004 Default Values | ||||
|---|---|---|---|---|
| ||||
I was looking at some example code and noticed that the author had used extra versions of overloaded functions to achieve what amounted to default values.
eg
foo(int a, int b)
{
foo(a, b, 5)
}
foo(int a, int b, int c)
{
....
}
were if default values were supported:
foo(int a, int b, int c = 5)
{
....
}
would do the trick. I appreciate that the compiler may be able to reduce both to almost the same thing, but....
thoughts?
| ||||
April 14, 2004 Re: Default Values | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Scott Egan | "Scott Egan" <scotte@tpg.com.aux> wrote: > I was looking at some example code and noticed that the author had used extra versions of overloaded functions to achieve what amounted to default values. > thoughts? Personally, I like the C++ way of doing it (probably through familiarity over the years), as it seems simple, useful, and less verbose than writing a set of extra functions. But I think Walter may not like it for D. This has been discussed a lot recently. -- dave | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply