December 28, 2012
Good idea, but honestly what we really need is a "static foreach"

December 28, 2012
F i L:

> Good idea, but honestly what we really need is a "static foreach"

I opened this time ago, but this is another topic, and it's better to keep threads separate:
http://d.puremagic.com/issues/show_bug.cgi?id=4085

Bye,
bearophile
December 29, 2012
On Friday, December 28, 2012 19:17:45 Peter Alexander wrote:
> On Friday, 28 December 2012 at 10:58:59 UTC, bearophile wrote:
> > An alternative idea (that I maybe I proposed years ago in a
> > weaker form) is to introduce 'private' default arguments (they
> > must have a default value):
> > 
> > Is this little feature worth the amount of language complexity increase it causes?
> 
> I don't think it is, given how easy it is to work around.

Agreed. All you need to do is create an inner function which holds the majority of the function's body or a private function which does the same (and it can even have exactly the same if you want it to avoiding the need to come up with another name). I really think that this is a non-issue.

- Jonathan M Davis
December 29, 2012
Jonathan M Davis:

> I really think that this is a non-issue.

It's not a necessary feature, but it helps make the code more readable, shorter, keeping it safe. I write several recursive functions, and I'd like a way to refer to the function inside the function without using its real name, something like self(), or even __function(). Private default arguments help further the use of recursion.

Bye,
bearophile
December 29, 2012
On Saturday, December 29, 2012 07:01:42 bearophile wrote:
> Jonathan M Davis:
> > I really think that this is a non-issue.
> 
> It's not a necessary feature, but it helps make the code more readable, shorter, keeping it safe. I write several recursive functions, and I'd like a way to refer to the function inside the function without using its real name, something like self(), or even __function(). Private default arguments help further the use of recursion.

AFAIK, not even functional languages where recursion is what you always do have anything like what you're suggesting. I really don't see it as any real cost to do recursion use the function's name. So, feel free to bring it up as a feature that you'd like, but I really think that it's trying to solve something that really isn't a problem in the first place. And this is coming from someone who used to program in haskell quite a bit.

- Jonathan M Davis
December 30, 2012
Jonathan M Davis:

> AFAIK, not even functional languages where recursion is what you always do have anything like what you're suggesting.
> ...
> And this is coming from someone who used to program in haskell
> quite a bit.

The little enhancement request discussed here requires default arguments.
Function languages like Haskell don't have default arguments (despite there are some ways to have them  http://neilmitchell.blogspot.it/2008/04/optional-parameters-in-haskell.html ), so you can't compare well the two situations.

Bye,
bearophile
1 2
Next ›   Last »