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

Mailing lists / fpc-pascal / 2013-03
8 messages · 6 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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
"Xiangrong Fang" wroteHi 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
Is it possible for class helpers to be "selective"? i.e. attach to a specific object of…
That would change the class model to prototyping (as in Lua, JavaScript, etc.), which is not how it's implemented in Object Pascal...
"leledumbo" wroteThat 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
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
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
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.
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.