Re: Explicit-ness

David Jarvie lists at astrojar.org.uk
Thu Aug 31 11:48:39 BST 2006


On Thursday 31 August 2006 10:12, Allen Winter wrote:
>On Thursday 31 August 2006 04:57, David Jarvie wrote:
>> On Thursday 31 August 2006 1:35, Allen Winter wrote:
>> >On Wednesday 30 August 2006 18:59, Thiago Macieira wrote:
>> >> Allen Winter wrote:
>> >> > - constructor must be public
>> >> > - constructor must have exactly 1 required argument
>> >> > - constructor may have 1 or more optional arguments
>> >> > - a class may have more than constructor declared 'explicit'
>> >> > - copy constructors should not be declared 'explicit'
>> >> > - templates ignored
>> >> 
>> >> One more rule:
>> >> - constructor is not intentionally implicit
>> >> 
>> >> I have no idea how to detect that last one. But it is a valid use-case.
>> >> 
>> >Yeah, I just ran into just such a case.
>> >
>> >For now I will have Krazy ignore lines with a C++ comment saying
>> >to keep the constructor explicit, or that is should be implicit.
>> >
>> >All the following will be ignored, for example:
>> >   Duration(int seconds);  //implicit
>> >   Duration(int seconds); // not explicit
>> >   Duration(int seconds): //please do not make explicit
>> 
>> Do you mean these exact comments, or are they just examples? 
>They are just examples.
>Basically Krazy will skip the explicitness check on lines that contain
>the word "explicit" or the word "implicit".

Yes, a simple check for the presence of "explicit" or "implicit" would do the job well. No implicitly implicit constructors from now on! 
(acknowledgements to Thiago for the wording).

>>I think that a keyword
>> (analogous to apidox ones) would be better so that  people can word the comments
>> as they like as long as the keyword is included. 
>> 
>maybe we should just skip any line that contains the string "krazyskipme"
>in a C++ comment??
>
>i.e.
>next if ($line =~ +//.*krazyskipme+);

Perhaps we should have vim and emacs macros to automatically append a "krazyskipme" comment to random lines in a source file. That would 
add a touch of stylistic elegance to even the most poorly written or formatted code.

--
David Jarvie.





More information about the kde-core-devel mailing list