zensan / pascal.today

9 stars 3 forks source link

Getting rid of the constructor constraint #1

Closed Memnarch closed 8 years ago

Memnarch commented 8 years ago

Currently the Arc is supposed to be a container, but at the same time manages instance creation of the encapsulated Value.

There is no need for the constructing of the value in usual cases (means everything without WITH).

var
  LValue: Arc<TFoo>;
begin
  LValue := TFoo.Create();
end;

The implicit operator does the job. Constrained is only usefull for the WITH example, which is considered bad practice.

I'd propose to remove the buildin Instance creation in favour of functionality.

zensan commented 8 years ago

Hi!

Thanks for feedback! But mainly I use on my taste and the basis is borrowed from Marco Cantu book. You are free to make any adjustments. The WITH examples were just for illustration purposes.

Best regards, Zigmund.

On Tue, Aug 9, 2016, 12:53 Alexander Benikowski notifications@github.com wrote:

Currently the Arc is supposed to be a container, but at the same time manages instance creation of the encapsulated Value.

There is no need for the constructing of the value in usual cases (means everything without WITH).

var LValue: Arc; begin LValue := TFoo.Create(); end;

The implicit operator does the job. Constrained is only usefull for the WITH example, which is considered bad practice.

I'd propose to remove the buildin Instance creation in favour of functionality.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zensan/pascal.today/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AD0coTr-LxZCYasamDzB28mo84ykgiJbks5qeE4cgaJpZM4Jf5-y .

zensan commented 8 years ago

Hi again!

I read your e-mail now on fresh mind (not at midnight). I see your idea and actually agree. I will incorporate your suggestion as soon as i have time.

Thank you again and sorry that i did not understand you from the first time at night ;)

On Tue, Aug 9, 2016, 12:53 Alexander Benikowski notifications@github.com wrote:

Currently the Arc is supposed to be a container, but at the same time manages instance creation of the encapsulated Value.

There is no need for the constructing of the value in usual cases (means everything without WITH).

var LValue: Arc; begin LValue := TFoo.Create(); end;

The implicit operator does the job. Constrained is only usefull for the WITH example, which is considered bad practice.

I'd propose to remove the buildin Instance creation in favour of functionality.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zensan/pascal.today/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AD0coTr-LxZCYasamDzB28mo84ykgiJbks5qeE4cgaJpZM4Jf5-y .

zensan commented 8 years ago

Fixed in master.

Memnarch commented 8 years ago

Cool, and thanks :)