 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Serge Dosyukov Guest
|
Posted: Fri Aug 29, 2003 12:16 am Post subject: Re: New Language Feature |
|
|
You can get this with interfaces implemented by objects
--
Serge Dosyukov
Borland Delphi 6 product certified
MCP
"Programming is not a job; it is a style of life."
|
|
| Back to top |
|
 |
Erwien Saputra Guest
|
Posted: Fri Aug 29, 2003 12:16 am Post subject: Re: New Language Feature |
|
|
Max wrote:
| Quote: | Delphi should support a garbage collection. Something like:
|
I already has something like that using Interface, and D.Net will have it.
I think it should be all or nothing. Otherwise in some parts it might
have garbage on, while on other parts have garbage off. Debugging can
be challenging.
Wien.
|
|
| Back to top |
|
 |
David Clegg Guest
|
Posted: Fri Aug 29, 2003 12:37 am Post subject: Re: New Language Feature |
|
|
Erwien Saputra <erwien (AT) nospam (DOT) codeline.dot.net> wrote in
news:3f4e9b5d$1 (AT) newsgroups (DOT) borland.com:
| Quote: | I think it should be all or nothing. Otherwise in some parts it might
have garbage on, while on other parts have garbage off. Debugging can
be challenging.
|
<ToungeFirmlyPlantedInCheek>
Nah, bring it on! With the modern IDEs we have, this programming lark is
getting too easy anyway.
</ToungeFirmlyPlantedInCheek>
--
Cheers,
David Clegg
dclegg_at_ebetonline_dot_com
{$IFDEF Alessandro}Italian{$ELSE}French{$ENDIF} is the language of love.
For everything else there's Delphi^h^h^h^h^h^h C#.
|
|
| Back to top |
|
 |
Dave Nottage (TeamB) Guest
|
Posted: Fri Aug 29, 2003 12:38 am Post subject: Re: New Language Feature |
|
|
Alessandro Federici wrote:
| Quote: | If you are willing to deal with recirsive references, temp-variables
that the compilers plugs in your code (and which really mess things
up sometimes) and also remember to use weak references <G> It's
slightly more complicated with ref counting and sort of slower.
|
Can you give some examples? I guess I haven't had the kind of troubles
you've had.
--
Dave Nottage (TeamB)
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Fri Aug 29, 2003 12:41 am Post subject: Re: New Language Feature |
|
|
"Serge Dosyukov" <serge@argosoftware[DOT]com> wrote
| Quote: | Apparently I'm oppose to garbage collector at this moment because it
making
a language less structural (I hope it is a correct word)
People will forgot to free objects or will expect what object isn't free
yet... |
I was not too pro-GC either but I changed my pov on the matter.
Point is that even with interfaces it's not always true it happens when you
believe it should...
It really bit me and Marc in the but many times.
| Quote: | This is good for .Net, because it is paradigm of .net, it might be a good
idea for today's mind.
And I agree with Erwien, it is all or nothing
|
Ditto. I have to admit it's something that should have always been there...
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Fri Aug 29, 2003 12:48 am Post subject: Re: New Language Feature |
|
|
"Dave Nottage (TeamB)" <davidn (AT) nospamola (DOT) smartchat.net.au> wrote
| Quote: | If you are willing to deal with recirsive references, temp-variables
that the compilers plugs in your code (and which really mess things
up sometimes) and also remember to use weak references <G> It's
slightly more complicated with ref counting and sort of slower.
Can you give some examples? I guess I haven't had the kind of troubles
you've had.
|
Yes but I will be quick (I promise I can answer more precisely if you need
me to <G>). The temp variable thing is complex and I cleaned up all my code
not to get into those situations anymore so I don't have a real example
(anymore). Basically happens when you use "as" and in a set of other
situations such as results of methods. Actually I have one (sort of new. I
hit it yesterday).
begin
pkg := LoadPackage(whatever);
GetprocAddress(bla blah)
myintf := PackageFunction ThatReturnsOneIntd;
UnloadPackage;
<BAM>
end;
Basically you need to NIL myintf begore unloading the package. This is a
silly example, but it is just to say it's not as simple as with GC...
The "as" issue is nastier instead but again, I 've no handy sample
(anymore).
The recursive refernce thing instead is simple to get into: Master has a
refernce to child and child has one to master. When you have a situation
like this, you have to use a weak pointer in either one, otherwise objects
won't get freed.
The speed thing was demonstrated by MS at a ceonference here in Chicago. The
AddRef/Release overhead was seriously big.
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Fri Aug 29, 2003 12:50 am Post subject: Re: New Language Feature |
|
|
"Alessandro Federici" <nomore (AT) spam (DOT) forme> wrote
FTR, this stuff is not really Delphi specific, don't get me wrong
Happens with VC++ and COM in general as well. It's pattern related.
I like refcounting don't get me wrong. It's just that is not *that simple*
all the times )
|
|
| Back to top |
|
 |
Dave Nottage (TeamB) Guest
|
Posted: Fri Aug 29, 2003 12:54 am Post subject: Re: New Language Feature |
|
|
Alessandro Federici wrote:
| Quote: | begin
pkg := LoadPackage(whatever);
GetprocAddress(bla blah)
myintf := PackageFunction ThatReturnsOneIntd;
UnloadPackage;
BAM
end;
|
Interesting. If I have time, I'll have a play with this one.
| Quote: | The recursive refernce thing instead is simple to get into: Master
has a refernce to child and child has one to master. When you have a
situation like this, you have to use a weak pointer in either one,
otherwise objects won't get freed.
|
OK.. I was aware of that one, but thanks <g>
| Quote: | The speed thing was demonstrated by MS at a ceonference here in
Chicago. The AddRef/Release overhead was seriously big.
|
OK.. I'll have a look and/or play with this one when I have time.
--
Dave Nottage (TeamB)
|
|
| Back to top |
|
 |
Ingvar Nilsen Guest
|
Posted: Fri Aug 29, 2003 1:18 am Post subject: Re: New Language Feature |
|
|
Alessandro Federici wrote:
| Quote: | You can get this with interfaces implemented by objects
If you are willing to deal with recirsive references, temp-variables
that
the compilers plugs in your code (and which really mess things up
sometimes) and also remember to use weak references <G> It's
slightly more complicated with ref counting and sort of slower.
|
You're exaggerating.
I understand it can be complicated under certain circumstances, but
talking for myself, I use interfaces all the time, love interfaces,
cannot program without them.
I always add debug code to test whether they are freed. They are.
All is fine <g>
When you start using UML in Delphi, you will really understand how to
appreciate interfaces, UML and interfaces seem to be made for
each others :)
--
Ingvar Nilsen
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Fri Aug 29, 2003 2:54 am Post subject: Re: New Language Feature |
|
|
"Ingvar Nilsen" <telcontr@[Remove-This-Part]online.no> wrote
| Quote: | You're exaggerating.
I understand it can be complicated under certain circumstances, but
talking for myself, I use interfaces all the time, love interfaces,
cannot program without them.
|
I love interfaces too You should know me <G>
Anyhow, I made some concrete examples.
| Quote: | I always add debug code to test whether they are freed. They are.
All is fine <g
|
Actually that depends
what you're doing.
That is all I am saying (and backing up with examples). Intfs are *great*.
No questions. Just not always that simple.
GC is simpler (probabily).
| Quote: | When you start using UML in Delphi, you will really understand how to
appreciate interfaces, UML and interfaces seem to be made for
each others
|
I never needed UML to love interfaces and our products are *heavily* based
on those and on tricks about them not everybody knows <G>
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Fri Aug 29, 2003 3:09 am Post subject: Re: New Language Feature |
|
|
"Alessandro Federici" <nomore (AT) spam (DOT) forme> wrote
| Quote: | When you start using UML in Delphi
|
To enforce my message: OO without interfaces is worth (almost) squat. It's a
whole different world once you start using them
What started me on interfaces is COM. That's another reason for which I
consider it something every Delphi developer should know well.
But that's me ;-)
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Fri Aug 29, 2003 3:23 am Post subject: Re: New Language Feature |
|
|
"Ingvar Nilsen" <telcontr@[Remove-This-Part]online.no> wrote
| Quote: | When you start using UML in Delphi, you will really understand how to
appreciate interfaces, UML and interfaces seem to be made for
each others
|
BTW keep in mind that reference counting for interfaces is a
COMism/Delphism.
Interfaces have a lot of sense and exist without ref counting in other
languages.
IMHO refcounting is of very little weight compared to the other benefits of
interfaces (i.e. breaking vertical dependencies on parent classes).
|
|
| Back to top |
|
 |
Erwien Saputra Guest
|
Posted: Fri Aug 29, 2003 4:03 am Post subject: Re: New Language Feature |
|
|
Alessandro Federici wrote:
| Quote: |
I never needed UML to love interfaces and our products are *heavily* based
on those and on tricks about them not everybody knows
|
Hei, you are not allowed to make people curious to buy your product and
to find the trick in this NG, you know... :)
That kind of post should be in 3rd party NG. ^_^
Wien.
|
|
| Back to top |
|
 |
Karl Waclawek Guest
|
Posted: Fri Aug 29, 2003 4:36 am Post subject: Re: New Language Feature |
|
|
"Vincent Parrett (Atozed Software)" <vincent@.nospam.atozedsoftware.com> wrote in
message news:3f4ed139 (AT) newsgroups (DOT) borland.com...
| Quote: | I can think of one simple case that can be a real gotcha when using
interfaces. See the example unit code below.. call NewITest to create an
ITest object, and then call the DoSomething Method. You would expect the
reference count to be 1, but in fact it's 2. In this simple example this is
no big deal as somehow the object still gets released.. however if something
else increments the reference count (ie something internal to the code) then
that's when the real problems start happening.... if I have code like this :
var
myTest : ITest;
begin
myTest := NewITest;
mTest.DoSomething;
end;
|
It is quite likely that myTest and the Result variable
in NewITest both contribute to the reference count separately,
as the Result variable must exist independently. This is because
the compiler must be prepared to handle the case where NewITest
is called without assigning the result to a variable.
I assume (without testing it) that even if you
set myTest := nil you still have a reference count of 1,
and it only goes to zero when the (hidden) Result variable
goes out of scope.
The same issues arise with the "as" operator and the
use of "with". Check out QC # 2437.
| Quote: |
This would be fine, however if something internal to the DoSomething method
caused an addref then you could end up with an orphaned object without
realising it. Replacing
myTest := NewITest
with this
myTest := TTest.Create;
results in a ref count of 1 and it's less likely that you will end up with
an orphaned object.
|
Actually, the above is fairly safe, except for border cases like
in QC # 2437. But orphaned objects won't happen this way.
Karl
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Fri Aug 29, 2003 4:59 am Post subject: Re: New Language Feature |
|
|
"Erwien Saputra" <erwien (AT) nospam (DOT) codeline.dot.net> wrote
| Quote: | Hei, you are not allowed to make people curious to buy your product and
to find the trick in this NG, you know...
That kind of post should be in 3rd party NG. ^_^
|
Actually I am thinking of a BDN article ;-)
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|