| Thread overview | |||||
|---|---|---|---|---|---|
|
March 19, 2007 Abstract functions with bodies | ||||
|---|---|---|---|---|
| ||||
While porting DMD code to Java I noticed that error reporting for abstract functions with bodies is disables. The following code gives no errors:
class X {
abstract int bla() {
return 1;
}
}
Why is the error reporting silenced for this (in FuncDeclaration::semantic )?
Ary
| ||||
March 19, 2007 Re: Abstract functions with bodies | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ary Manzana | Ary Manzana escribió: > While porting DMD code to Java I noticed that error reporting for abstract functions with bodies is disables. The following code gives no errors: > > class X { > > abstract int bla() { > return 1; > } > > } > > Why is the error reporting silenced for this (in FuncDeclaration::semantic )? > > Ary Right from the docs (http://www.digitalmars.com/d/attribute.html#abstract): "Functions declared as abstract can still have function bodies. This is so that even though they must be overridden, they can still provide 'base class functionality.'" Regards, -- Tom; | |||
March 19, 2007 Re: Abstract functions with bodies | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tom | Tom escribió:
> Ary Manzana escribió:
>> While porting DMD code to Java I noticed that error reporting for abstract functions with bodies is disables. The following code gives no errors:
>>
>> class X {
>>
>> abstract int bla() {
>> return 1;
>> }
>>
>> }
>>
>> Why is the error reporting silenced for this (in FuncDeclaration::semantic )?
>>
>> Ary
>
> Right from the docs (http://www.digitalmars.com/d/attribute.html#abstract):
>
> "Functions declared as abstract can still have function bodies. This is so that even though they must be overridden, they can still provide 'base class functionality.'"
>
> Regards,
> --
> Tom;
I never thought of that, but it pretty useful. Great! :-)
Thanks,
Ary
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply