A few comments about D

bearophile bearophileHUGS at lycos.com
Tue Aug 23 17:20:18 PDT 2011


Andrej Mitrovic:

>"Walter Bright is considering adding a compile-time flag that would banish all constructs that make implicit use of the GC, in which case you'll know at compile time where the culprits are, and you can change your code accordingly."<

I think producing an error for each GC allocation in the current compilation unit is a bit harsh.

To face this kind of problems I (with ideas from other people) have suggested (both are in Bugzilla with more explanations):

1) A transitive attribute like @noheap (or maybe @nogcheap) that statically disallows GC allocations inside a function (and the functions it calls), so they become errors. (Don doesn't like this idea much, I don't know why). Even better is to give the library programmer the tools to create a @noheap by herself. This means introducing user-defined attributes in D2 and adding more static introspection, to allow the implementation & running of this recursive testing code at compile time (maybe Don appreciates this idea more).

2) A compiler switch that produces a warning for each line of code where there is a closure allocation on the heap. A variant of this idea is to produce a warning for each line of code that causes a GC allocation.

Bye,
bearophile


More information about the Digitalmars-d mailing list