From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Compile time executed functions
Date: Wed, 28 Mar 2001 10:12:56 -0600
Date: 2001-03-28T16:11:54+00:00 [thread overview]
Message-ID: <99t2ga$c7n$1@hobbes2.crc.com> (raw)
In-Reply-To: Minw6.344$bY4.291@www.newsranger.com
Just to set the record straight -- the original poster's example was a CRC
lookup table -- not something that would involve the halting problem.
I had the same problem years ago when writing JOVIAL for the
AC-130 gunship. We had to do a number of diagnostic tasks in the
idle task -- one of which was to do a CRC check on the text and constant
data areas of memory, to make sure they hadn't changed.
My solution to the table generation problem was to write a standalone
program that generated the table and wrote it to a file in JOVIAL
source code format, to be included in the source to be compiled.
"Ted Dennison" <dennison@telepath.com> wrote in message
news:Minw6.344$bY4.291@www.newsranger.com...
> In article <874rweoo2p.fsf@deneb.enyo.de>, Florian Weimer says...
> >
> >Ted Dennison<dennison@telepath.com> writes:
> >
> >> >You build the function (or a lambda expression) using the usual
> >> >methods, and then call COMPILE on it. Simple, isn't it? ;-)
> >
> >> But that just generates code for the function, right?
> >
> >Yes, but this way, values can be computed prior to run time which
> >appear to be constants (even during compile time) but are in fact not.
>
> Ahhh. But that's not what he was talking about. He wants to be able to
supply
> some arbitrary function (like say an integrator or a matrix math routine
or a
> search routine) which the compiler will then run during the compile phase,
find
> the value of the result (eg: 3.57) and then place that value in a constant
which
> he can have the compiler stick in the ROM section of the generated code.
In
> order to stick a value in the ROM section, it clearly cannot be computed
at
> runtime. It has to be calulated by the compiler at compile time and built
into a
> ROM section in the reulting executable.
>
> After thinking about this some more, I'll go so far as to say that I don't
think
> there are *any* languages that supply this capability. If there are, there
> certianly aren't many. The reason is as follows:
>
> Let us assume there is a compiler X that allows any aribitrary routine to
be
> supplied which it will run during the compile phase, find the result, and
store
> that result value in a constant. There are two possible approaches that X
can
> take to support this capability.
>
> Approach 1 is that compiler X makes no attempt to verify that the supplied
> routine is valid. In this case, it would be possible for the user to
supply a
> non-halting routine to the compiler (eg: an estimating integration routine
that
> has a bug where it never converges). Thus a compiler that takes approach 1
can
> under some circumstances go into an infinte loop during compilation due to
a bug
> in user code, and it must be the user's responsiblily to prevent this, and
to
> detect the condition when it occurs (vs. a routine that just takes a long
time)
> and kill the compiler somehow. This must be accepted as normal operation
of
> compiler X(1).
>
> Approach 2 is that compiler X does not accept non-halting routines.
However,
> this means compiler X(2) is magic, since the halting problem has been
proven to
> be unsolvable in the general case. Whatever you do, don't tick off the
developer
> of X(2)! :-)
>
> I'd claim that most developers will not accept the responsibility of an
X(1)
> compiler, and X(2) is impossible. The only possible way out is to somehow
put
> restrictions on the routines that may be supplied to the compiler so that
all
> possilbe non-halting routines are disallowed. That pretty much means
nothing
> with a loop (except possibly a for loop) or a goto, or another subroutine
call
> (recursion is another type of loop, but this may be softened by building
and
> checking some kind of call tree at compile time instead). These
restrictions
> would allow some simple subroutines, but nothing complicated like a
> pointer-based list search or an estimating integrator, which is the kind
of
> stuff the original poster wanted to use.
>
> ---
> T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html
> home email - mailto:dennison@telepath.com
next prev parent reply other threads:[~2001-03-28 16:12 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-27 7:10 Compile time executed functions Mats Karlssohn
2001-03-27 13:30 ` Ken Garlington
2001-03-28 7:08 ` Mats Karlssohn
2001-03-28 19:07 ` Phaedrus
2001-03-29 7:41 ` Mats Karlssohn
2001-03-29 5:02 ` Ken Garlington
2001-03-29 7:58 ` Mats Karlssohn
2001-03-29 14:28 ` Ken Garlington
2001-03-29 14:48 ` Ted Dennison
2001-04-04 7:52 ` Mats Karlssohn
2001-04-04 14:05 ` Ted Dennison
2001-04-05 6:30 ` Mats Karlssohn
2001-03-29 19:48 ` Simon Wright
2001-03-31 19:30 ` Ken Garlington
2001-04-04 7:53 ` Mats Karlssohn
2001-03-30 10:41 ` Jean-Marc Bourguet
2001-03-30 16:13 ` Ken Garlington
2001-03-30 16:47 ` Jean-Marc Bourguet
2001-03-30 18:54 ` Stephen Leake
2001-04-01 8:42 ` Jean-Marc Bourguet
2001-03-31 19:30 ` Ken Garlington
2001-04-01 8:59 ` Jean-Marc Bourguet
2001-04-01 18:22 ` Ken Garlington
2001-04-02 9:30 ` Jean-Marc Bourguet
2001-04-02 12:42 ` Robert A Duff
2001-04-02 14:16 ` Jean-Marc Bourguet
2001-04-03 0:33 ` Pat Rogers
2001-04-02 13:09 ` Ken Garlington
2001-04-02 13:40 ` Robert A Duff
2001-04-02 23:29 ` Ken Garlington
2001-04-13 23:11 ` Robert A Duff
2001-04-02 14:32 ` Jean-Marc Bourguet
2001-04-04 7:59 ` Mats Karlssohn
2001-04-04 7:47 ` Mats Karlssohn
2001-04-06 0:33 ` Ken Garlington
2001-04-09 12:21 ` Mats Karlssohn
2001-04-13 15:51 ` Tucker Taft
2001-03-27 14:39 ` Ted Dennison
2001-03-27 16:40 ` Mark Biggar
2001-03-27 18:14 ` Florian Weimer
2001-03-27 18:15 ` Florian Weimer
2001-03-27 18:57 ` Ted Dennison
2001-03-27 19:22 ` Florian Weimer
2001-03-27 20:23 ` Ted Dennison
2001-03-27 22:15 ` Florian Weimer
2001-03-27 23:30 ` Georg Bauhaus
2001-03-28 9:54 ` Florian Weimer
2001-03-28 15:20 ` Ted Dennison
2001-03-28 16:12 ` David C. Hoos, Sr. [this message]
2001-03-28 21:15 ` Robert A Duff
2001-03-28 21:56 ` Brian Rogoff
2001-03-29 8:18 ` Mats Karlssohn
2001-03-29 8:11 ` Mats Karlssohn
2001-03-29 14:37 ` Ted Dennison
2001-03-29 16:35 ` Mark Biggar
2001-03-29 19:27 ` Florian Weimer
2001-03-29 19:28 ` Florian Weimer
2001-03-30 3:41 ` Ken Garlington
2001-03-30 4:32 ` Brian Rogoff
2001-03-30 14:27 ` Compile time executed functions [OT] Karel Thönissen
2001-03-30 17:30 ` Scheveningen (Re: Compile time executed functions [OT]) Ray Blaak
2001-03-30 17:39 ` More {OT] (Was " Brian Rogoff
2001-03-30 23:39 ` Karel Thönissen
2001-03-30 17:47 ` Compile time executed functions Brian Hanson
2001-03-30 0:06 ` Robert A Duff
2001-03-30 15:02 ` Ted Dennison
2001-03-30 20:57 ` Robert A Duff
2001-04-02 14:26 ` Ted Dennison
2001-03-30 17:33 ` Ray Blaak
2001-03-29 8:25 ` Florian Weimer
2001-03-28 7:17 ` Mats Karlssohn
2001-03-29 1:35 ` Jon S Anthony
2001-03-27 14:39 ` Robert A Duff
2001-03-27 15:09 ` Ted Dennison
2001-03-27 16:33 ` Robert A Duff
2001-03-27 23:36 ` Ken Garlington
2001-03-28 20:47 ` Mark Lundquist
2001-03-28 7:29 ` Mats Karlssohn
2001-03-28 22:15 ` Robert A Duff
2001-03-29 8:43 ` Mats Karlssohn
2001-03-31 4:12 ` Robert A Duff
2001-04-05 7:06 ` Mats Karlssohn
2001-04-13 23:18 ` Robert A Duff
2001-03-29 5:02 ` Ken Garlington
2001-03-28 7:31 ` Mats Karlssohn
2001-03-30 8:57 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox