Why some function are class-less?
Stefan Koch via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Nov 17 10:01:33 PST 2016
On Thursday, 17 November 2016 at 17:54:23 UTC, Suliman wrote:
> On Thursday, 17 November 2016 at 17:45:31 UTC, Stefan Koch
> wrote:
>> On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote:
>>> On Thursday, 17 November 2016 at 16:46:37 UTC, Steven
>>> Schveighoffer wrote:
>>>> On 11/17/16 11:28 AM, Suliman wrote:
>>>>> [...]
>>>>
>>>> D does not require classes to write functions. All a class
>>>> member function is anyway is a function with an implied
>>>> class instance parameter.
>>>>
>>>> -Steve
>>>
>>> Ok, but what profit? Could you give me an example (for
>>> example with logger)?
>>
>> for example writeln.
>> You would not want to create a stdio object just to call
>> writeln.
>
> Ok, but when the logger class may be more helpful that function
> usage?
If you log something you usually want to keep private state.
Classes are useful for that.
More information about the Digitalmars-d-learn
mailing list