DCT use cases - draft
David Piepgrass
qwertie256 at gmail.com
Wed Jul 25 16:46:40 PDT 2012
On Wednesday, 23 May 2012 at 15:36:59 UTC, Roman D. Boiko wrote:
> On Tuesday, 22 May 2012 at 18:33:38 UTC, Roman D. Boiko wrote:
>> I'm reviewing text right now
> Posted an updated version, but it is still a draft:
>
> http://d-coding.com/2012/05/23/dct-use-cases-revised.html
I think one of the key challenges will be incremental updates.
You could perhaps afford to reparse entire source files on each
keystroke, assuming DCT runs on a PC*, but you don't want to
repeat the whole semantic analysis of several modules on every
keystroke. (*although, in all seriousness, I hope someday to
browse/write code in a smartphone/tablet IDE, without killing
battery life)
D in particular makes standard IDE features difficult, if the
code uses a lot of CTFE just to decide the meaning of the code,
e.g. "static if" computes 1_000_000 digits of PI and decides
whether to declare method "foo" or method "bar" based on whether
the last digit is odd or even.
Of course, code does not normally waste the compiler's time
deliberately, but these sorts of things can easily crop up
accidentally. So DCT could profile its own operation and report
to the user which analyses and functions are taking the longest
to run.
Ideally, somebody would design an algorithm that, given a
location where the syntax tree has changed, figures out what
parts of the code are impacted by that change and only re-runs
semantic analysis on the code whose meaning has potentially
changed.
But, maybe that is too just hard. A simple approach would be to
just re-analyze the whole damn program, but prioritize analysis
so that whatever code the user is looking at is re-analyzed
first. This could be enhanced by a simple-minded dependency tree,
so that changing module X does not trigger reinterpretation of
module Y if Y does not directly or indirectly use X at all.
By using multiple threads to analyze, any long computations
wouldn't prevent analysis of the "easy parts"; but several
threads could get stuck waiting on the same thing. For example,
it would seem to me that if a module X contains a slow "static
if" at module scope, ANY other module that imports X cannot
resolve ANY unqualified function calls until that "static if" is
done processing, because the contents of the "static if" MIGHT
create new overloads that have to be considered*. So, when a
thread gets stuck, it needs to be able to look for other work to
do instead.
In any case, since D is turing-complete and CTFE may enter
infinite loops (or just very long loops), an IDE will need to
occasionally terminate threads and restart analysis, so the
analysis threads must be killable, but hopefully it could be
designed so that analysis doesn't have to restart from scratch.
I guess immutable data structures will therefore be quite
important in the design, which you seem to be aware of already.
More information about the Digitalmars-d
mailing list