[Issue 5140] Add __FUNCTION__

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 11 09:29:15 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=5140



--- Comment #14 from Rob T <alanb at ucora.com> 2013-01-11 09:29:13 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > I simply don't see any need to refer to a function anonymously when making a
> > recursive call. You can just use its name like you do anywhere else that you
> > call it. The _only_ advantage that I see is that you have fewer lines of code
> > to change when you change the function's name, but search and replace takes
> > care of that quite easily.
> 
> Do you mean you wish/prefer to write OOP like this in D?
> 
> 
> class Foo {
>     Foo(int x) {...}
>     void bar(Foo f) {
>         Foo g = new Foo(5);
>         ...
>     }
> }

Good points. I know what you say is true because I use recursion often enough
to see the advantages. The case for private default args is another solid
argument.

More generically speaking however, rather than being ad-hoc less-than-useful,
what is being proposed actually makes some of D's features more consistent with
the rest of D. For example the use of private args is more consistent with the
rest of D's features that already have private, such as structs, classes, and
modules. Disallowing private args is actually less consistent with the rest of
D and is a throw-back to the C era. The _function is actually consistent with
the use of "this" for structs and classes. Had these private args and anonymous
recursion been implemented from the start, the thought of removing them would
never be considered. If we had the chance to redesign D, we could actually make
it simpler to use and more powerful by making it more consistent.

--rt

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list