Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-03

Selective Class Helper

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xiangrong Fang

Hi There,

Is it possible for class helpers to be "selective"? i.e. attach to a specific object of that class, but not every instance? This would be useful for "behavior injection".

Thanks

Sven Barth
to Xiangrong Fang
"Xiangrong Fang" wrote
Hi There, Is it possible for class helpers to be "selective"? i.e. attach to a

specific object of that class, but not every instance? This would be useful for "behavior injection".

No, this is not possible.

Regards,
Sven

Sven Barth
to leledumbo
"leledumbo" wrote
That would change the class model to prototyping (as in Lua, JavaScript, etc.), which is not how it's implemented in Object Pascal...

I would more call it "Traits" which is at least a feature I'd like to research. This means that I'll implement it in a branch, will play with it and ask others to play with it and then we can decide whether we (as in "devs + community") want that feature in trunk.

Regards,
Sven

Xiangrong Fang
to Sven Barth

I vote for Traits. This will make FP more flexible... As a matter of fact, I was surprised to see operator overloading being implemented in pascal, which was a feature I like in C++, although I have never write a program more complex than cout << "Hello World" in that magnificent language. :-)

2013/3/14 Sven Barth

Show quoted text 17 lines
Am 13.03.2013 17:04 schrieb "leledumbo" : > > That would change the class model to prototyping (as in Lua, JavaScript, > etc.), which is not how it's implemented in Object Pascal... I would more call it "Traits" which is at least a feature I'd like to research. This means that I'll implement it in a branch, will play with it and ask others to play with it and then we can decide whether we (as in "devs + community") want that feature in trunk. Regards, Sven _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Juha Manninen
to Xiangrong Fang
Xiangrong Fang wrote
... which was a feature I like in C++, although I have never write a program more complex than cout << "Hello World" in that magnificent language. :-)

You consider it "magnificent" because you have not written anything complex with it.
Please try it yourself. After haunting all the bugs causing crashes and memory leaks it may not feel so magnificent any more.

Regards,
Juha

Reimar Grabowski
to Juha Manninen
You consider it "magnificent" because you have not written anything complex with it. Please try it yourself. After haunting all the bugs causing crashes and memory leaks it may not feel so magnificent any more.

No C++ bashing, please. I have worked on multi million line C++ projects and do not think that it is a bad language. FPC is not the be all end all of programming languages. Every language has it's merrits and it's flaws.

R.

Mark Morgan Lloyd
to Reimar Grabowski
Reimar Grabowski wrote 9 lines
On Thu, 14 Mar 2013 10:48:58 +0200 Juha Manninen wrote: > You consider it "magnificent" because you have not written anything > complex with it. > Please try it yourself. After haunting all the bugs causing crashes > and memory leaks it may not feel so magnificent any more. No C++ bashing, please. I have worked on multi million line C++ projects and do not think that it is a bad language. FPC is not the be all end all of programming languages. Every language has it's merrits and it's flaws.

In any event, memory leaks etc. in the compiler and standard libraries are generally a symptom of a poor implementation rather than of poor language design, and leaks and crashes in application code are generally a symptom of a deficient programming environment. Let us be thankful that Pascal's early adoption of managed strings shielded us from much of the pain caused by C, and that strong type checking protected us from most of the rest.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]