Disable GC entirely

Manu turkeyman at gmail.com
Tue Apr 9 21:32:43 PDT 2013


On 10 April 2013 04:29, Rob T <alanb at ucora.com> wrote:

> On Tuesday, 9 April 2013 at 16:49:04 UTC, Manu wrote:
>
>>
>>>>
>>>>  final class Foo{ //no inheritance
>>> final: //no virtuals
>>> ...
>>> }
>>>
>>> 2 extra words and you are done. The only problem I see is that there is
>>> no
>>> way to "undo" final on a few methods later...
>>>
>>
> final class Foo
> {
>    final //no virtuals
>    {
>       ...
>    }
>
>    // final ends, virtual methods below?
>    ....
>
> }
>

My point exactly. That is completely fucked.
final on the class means you can't derive it anymore (what's the point of a
class?), and the manual final blocks are totally prone to error.
In my experience, 90% of functions are not (or rather, should not be)
virtual. The common (and well performing) case should be default.

Any language with properties can't have virtual-by-default.
Seriously, .length or any other trivial property that can no longer be
inlined, or even just called.
And human error aside, do you really want to have to type final on every
function? Or indent every line an extra tab level?


And any junior/tired/forgetful programmer will
>> accidentally write slow code all over the place, and nobody will ever have
>> any idea that they've done it. It's very dangerous.
>>
>
> I suppose, OTOH forgetting to make methods virtual can lead to another
> problem.
>

No it can't. override is explicit. You get an error if you forget to make a
function virtual.
And even if that was a risk (it's not), I'd take that any day of the week.

In general, perhaps we're still talking about the same problem as with how
> to ensure that portions of code do not contain unwanted features of the
> language. If you want to ban the use of virtual functions, there ought to
> be a way to do it easily, same for writing code that does not contain
> features of the language that require a GC, etc.


I don't want to ban the use of virtual functions. I want to ban the use of
virtual functions that aren't marked virtual explicitly! ;)

Likewise, I like the GC, I just want to be able to control it.
Disable auto-collect, explicitly issue collect calls myself at controlled
moments, and give the collect function a maximum timeout where it will
yield, and then resume where it left off next time I call it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130410/3918fc5d/attachment.html>


More information about the Digitalmars-d mailing list