[comp.lang.c] I wanna do X.

bill@proxftl.UUCP (T. William Wells) (09/14/88)

In article <1409@pur-phy> sho@newton.physics.purdue.edu.UUCP (Sho Kuwamoto) writes:
: I *want* to be able to create an array and jump to it.  I do this all
: the time.  Granted, I do this on a micro (a Mac) so first of all, it's
: just more feasable, and second of all, there's no sophisticated memory
: management (or for that matter, not nearly as much need to worry about
: crashing the system) but still, I think it's a bit severe to say that
: such a thing should never be done.  Maybe it would be OK if the
: compiler gave you the option of explicitly coercing some piece of data
: into becoming code.

I'm getting real tired of the "I wanna do X" comments.  First,
there is almost (but now always) a better, standard way to do the
same thing.  And second, there seems to be a *major*
misunderstanding of what ANSI says.

ANSI does *not* say that you can't jump into your data.  All that
it says that this is not guaranteed to work.  In other words,
it's nonportable.  OF COURSE its nonportable.  It's just not
going to work on a machine with a different processor, and it may
not work with a different operating system or a different
compiler.

A similar comment applies to a lot of things that people are
complaining about.  ANSI rarely says that, at run time, certain
things are not allowed.  Instead, it says things like "if you do
X, the results are undefined (or implementation dependent)".

So you *can* write your incremental compiler and have it conform
to ANSI C (though it will not be maximally conforming).  You just
can't do that and assume that it will port.  And that is what you
would expect.

Let me make that clear: unless the ANSI standard says that the
compiler *must* prohibit something, that thing is *allowed*.  If
there is something reasonable to do on your particular system, so
long as doing it doesn't conflict with the do's and don'ts that
are stated in the standard, the compiler can do it.  And you can
use that feature to your hearts content, and have a conforming
program.  The program won't be maximally conforming, so it won't
necessarily port easily, but that is the cost of using a system
specific feature.

---
Bill
novavax!proxftl!bill