what is the difference between static method of the class, module method and static method of the module?

Era Scarecrow rtcvb32 at yahoo.com
Wed Jun 20 12:21:25 PDT 2012


On Wednesday, 20 June 2012 at 17:47:15 UTC, Jonathan M Davis 
wrote:
> On Wednesday, June 20, 2012 17:47:05 Alex Rønne Petersen wrote:
>> The static keyword has no effect on module functions, so 2 and 
>> 3 are equivalent. There is no significant difference between 
>> static class methods and module functions.
>
> The only difference is how they're called. createItem() vs 
> Item.createItem().

  I'd say just a little more than how they are called, it would be 
a direct relationship of the function with the class. Plus due to 
the direct relationship you can shorthand some of it (as long as 
it still makes sense).

  Although technically static functions are regular functions. But 
it's kinda like the difference of having enums internal vs 
external of a struct/class: Sometimes it just makes more sense 
(or localizes information a little more strongly).


More information about the Digitalmars-d-learn mailing list