Re: switch() Statement Question
- From: cri@xxxxxxxx (Richard Harter)
- Date: Thu, 02 Apr 2009 02:59:54 GMT
On Thu, 02 Apr 2009 01:52:31 +0100, Ben Bacarisse
<ben.usenet@xxxxxxxxx> wrote:
cri@xxxxxxxx (Richard Harter) writes:
On Wed, 1 Apr 2009 11:11:02 -0700 (PDT), jameskuyper
<jameskuyper@xxxxxxxxxxx> wrote:
lawrence.jo...@xxxxxxxxxxx wrote:
jameskuyper <jameskuyper@xxxxxxxxxxx> wrote:
It isn't a joke, it's a complaint about something that is written in a
way that makes it far less useful than it should be.
Then propose a concrete alternative. The committee would dearly love to
specify the limits in a more robust manner, but a number of very bright
people spent quite a lot of time on the issue and the "rubber teeth"
formation was the best they could come up with. Combinatorial explosion
is a bitch.
I'm not experienced in the art of compiler design; I don't know how to
choose the right way to impose such limits, and I don't know what
values would be sufficiently low to actually make implementation
feasible on essentially all existing platforms. I'm just (fairly)
certain that it should be feasible for some sufficiently broad and
sufficiently low set of limits. I fully appreciate your comment about
combinatorial explosions. However, while n! is in general a pretty big
number, 3! isn't too bad. How about taking all of the current limits,
add in a few more suggested by compiler experts, and then set the
values of all of those limits to 3. Start from there, and then see
which limits can be relaxed a little more than that.
This is actually a serious suggestion, not an April Fool's joke.
Probably a much better alternative is to say that a conforming
compiler must be able to compile any conforming translation unit
that is less than N chars in size after preprocessing and removal
of comments and white space. 100kb would provide for about 3000
lines of code (obviously depending on coding style).
That would oblige the compiler to accept the largest program of all of
the following example shapes that fit into 100kb:
struct a{struct b{struct c{struct d{... {int x}...}zw;}zx;}zy;}zz={42};
int main(void) {return zz.zy...;}
int main(void) {
int a_very_long_name_that_takes_up_almost_half_the_100k... = 42;
return a_very_long_name_that...;}
int main(void) {
int a=1,b=2,c=3...;
return a+b+c+...;}
int main(void) {
int a[1][1][1]... = {{{{{...{{{{42}}}}...}}}}};
return a[0][0]...;}
int main(void) { int i=0, f();
switch (f()) {case 0:return i++;case 1:return i++;...}}
and any of the thousands more convoluted examples that you can dream
up. I think it might be practical, but it would test the
implementor's imagination to be sure to have covered all bases!
And well the compiler should be able to handle these freaks. I
dare say I underestimate the difficulties, but it would seem that
if it has the space to hold the parse tree, it should have the
space to hold the subsequent transformations.
Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
If I do not see as far as others, it is because
I stand in the footprints of giants.
.
- Follow-Ups:
- Re: switch() Statement Question
- From: Keith Thompson
- Re: switch() Statement Question
- References:
- Re: switch() Statement Question
- From: lawrence . jones
- Re: switch() Statement Question
- From: jameskuyper
- Re: switch() Statement Question
- From: Richard Harter
- Re: switch() Statement Question
- From: Ben Bacarisse
- Re: switch() Statement Question
- Prev by Date: Re: switch() Statement Question
- Next by Date: Re: switch() Statement Question
- Previous by thread: Re: switch() Statement Question
- Next by thread: Re: switch() Statement Question
- Index(es):
Relevant Pages
|