Forbid the use of method name "init"

davidl at 126.com davidl at 126.com
Sat May 10 22:23:28 PDT 2008


在 Sun, 11 May 2008 05:46:57 +0800,Jarrett Billingsley  
<kb3ctd2 at yahoo.com> 写道:

> "Frank Benoit" <keinfarbton at googlemail.com> wrote in message
> news:g052dt$qt4$1 at digitalmars.com...
>> "init" and other class properties are kind of shadow-keywords.
>>
>> class MyClass{
>>   void init(){
>>   }
>> }
>>
>> The class is fine and can be used.
>> Now someone attempts to insert this class into a container....
>>
>> template Templ(T){
>>   T t = T.init; // Compile error
>> }
>>
>> The compiler should forbid the use of the method name "init", if the
>> signature does not make any sense for an "init" property. It must be a
>> static method, with a return value and no arguments.
>
> This should extend to any semi-reserved name.  The compiler used to allow
> redefinition of 'sizeof' and 'offsetof' but checks were added to disallow
> that.  That mechanism should just be extended.
>
>

I filed a bug of forbiding the use of stringof method. But it's markd as  
invalid :(
http://d.puremagic.com/issues/show_bug.cgi?id=1412

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list