473,394 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

any chance we will get tail calls in C# 4.0?

A tail call is a way of removing the current method from the stack
before recursing. See http://blogs.msdn.com/shrib/archive/...25/360370.aspx
.. I would love to see it in C# 4.0 and wouldn't mind if we needed a
special keyword to make it happen.
Nov 6 '08 #1
3 2038
On Thu, 06 Nov 2008 10:30:52 -0800, not_a_commie <no********@gmail.com>
wrote:
A tail call is a way of removing the current method from the stack
before recursing. See
http://blogs.msdn.com/shrib/archive/...25/360370.aspx
. I would love to see it in C# 4.0 and wouldn't mind if we needed a
special keyword to make it happen.
I doubt you'd see that. Tail recursion is so trivially implemented as a
plain iterative loop, I can't imagine that such a feature would meet the
bar for inclusion in the language.

I see why MSIL might have "tail" for supporting functional languages, but
this doesn't seem like something that needs to be exposed in C#. Any code
that could take advantage of it really just should be written differently
anyway.

Pete
Nov 6 '08 #2
Peter Duniho wrote:
On Thu, 06 Nov 2008 10:30:52 -0800, not_a_commie
<no********@gmail.comwrote:
>A tail call is a way of removing the current method from the stack
before recursing. See
http://blogs.msdn.com/shrib/archive/...25/360370.aspx
. I would love to see it in C# 4.0 and wouldn't mind if we needed a
special keyword to make it happen.

I doubt you'd see that. Tail recursion is so trivially implemented
as a plain iterative loop, I can't imagine that such a feature would
meet the bar for inclusion in the language.
I think more generally, switch/goto case (there's no requirement that the
tail call has to be recursion back to the same function, all participating
functions would have to be combined and turned into different case blocks in
a single master function).
>
I see why MSIL might have "tail" for supporting functional languages,
but this doesn't seem like something that needs to be exposed in C#. Any
code that could take advantage of it really just should be
written differently anyway.

Pete

Nov 6 '08 #3
"not_a_commie" <no********@gmail.comwrote in message
news:21**********************************@r37g2000 prr.googlegroups.com...
>A tail call is a way of removing the current method from the stack
before recursing. See
http://blogs.msdn.com/shrib/archive/...25/360370.aspx
. I would love to see it in C# 4.0 and wouldn't mind if we needed a
special keyword to make it happen.

This should be a compiler optimization as it's very easy to detect and even
easier to implement once detected.

Mike.
Nov 6 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Christopher T King | last post by:
Is it feasable, and/or desirable to have Python optimize tail-recursive calls, similar to Scheme and gcc -O2? i.e. effectively compile this: def foo(n): return foo(n-1) into this: def...
1
by: Stephen Thorne | last post by:
Decorators have been getting lots of air-time at the moment, but only really the syntax. After a short discussion on irc the other night I decided to download python2.4 from experimental and write...
10
by: Mel | last post by:
i need to create a unix like "tail" function on my site. the question: the text is displayed in a scrolled area and a new line is added at the end and the entire text is scrolled down so that...
2
by: nkharan | last post by:
Hey, Here is the pseudocode of quicksort. It can be observed that there are as many as (n-1) unresolved stack calls in the worst case. Now, how do i reduce this unresolved stack calls? what...
19
by: Kay Schluehr | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691
30
by: Chas Emerick | last post by:
I looked around for an ElementTree-specific mailing list, but found none -- my apologies if this is too broad a forum for this question. I've been using the lxml variant of the ElementTree API,...
6
by: lak | last post by:
i want to write a program that implement tail and tail -f command in unix. can any one help me in this?
4
by: ssecorp | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 so I try it and when I run: @Decorators.tail_recursion def fibtr(n): def fibt(a, b, n): if n <= 1: return b else: return...
35
by: Muzammil | last post by:
int harmonic(int n) { if (n=1) { return 1; } else { return harmonic(n-1)+1/n; } } can any help me ??
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.