Re: Delphi for XCode?
- From: Marco van de Voort <marcov@xxxxxxxx>
- Date: 16 Dec 2007 05:01:44 -0700
On 2007-12-15, Robert Giesecke <spam@xxxxxxxxx> wrote:
Marco van de Voort wrote:
I've had less trouble with it than with GC going rampant :-)Do you mind explaining what had happened to you?
The only 2 things about GCs, I do not like is the whole-world-stops kind of actually reclaiming
memory, and that it moves blocks when they are promoted to the next generation,
See msg to Rudy, and the early posted link about a similar .NET situation.
And yes, it was related to the world stops, but worse, postponing that so
long that the world stops pretty long. Together with the fact that the
project had started with the premise "Great, you don't have to free memory
anymore", and there was always some reference left in some bit of business
code that kept a cloud of objects alive.
That was a bit of shocker (but most of that was before I got dragged into
it, I was Delphi programmer, but when the situation got bad, I had to help
too)
And nested functions. I btw don't really miss it, I do miss a function pointer (function+frame) for
nested functions though. For iterator use (like TP's TCollection.Foreach)
Delegates could work with ref counting as well, but what about anonymous methods, hmm?
What about them? Why does an method need to be anonymous in the first place?
Anonymous methods are a substitution for nested methods in exactly the case you outlined above: When
you need a pointer to it, but want to have access to all values that are in scope,
Let me give an abstract example in Chrome:
var someInt := -1;
var someList := new List<Integer>([4, 51, 1, 18]);
someList.Sort(method(left, right : Integer) : Integer;
begin
result := someInt * left.CompareTo(right);
end);
As you can see, I can use "someInt" inside the method, but it is still compatible to the signature
that is accepted by "Sort".
The compiler created a hidden class, with a field that could take "someInt".
Now, every time the delegate gets executed, its method has access to that value.
When how what creates ? Try to make this a bit more sequential. I declare
this, then that, then the compiler does this, and when I call this with
that, that and that goes on under the hood.
Soooo, how to manage the lifetime of this hidden class' instance w/o a GC?
I have no
It is a royal PITA that there is no such thing.
If you add multi cast functionality, we could even use events instead of more complex notifications in
our code. (sorry, but a single subscriber is clearly not enough)
Of course you can have the compiler execute e.g. an array of events.
Uh! That would be just *horrible*. I very much prefer my current observer or visitor implementations
for notifications,
Wrap it in a class if you like, the point is that I still don't see the need for any language
alternations in your plea.
You don't even need compiler mods for that. Somehow I miss your point though.Well, if you added Delegates (function + method pointers that is) with multi cast support, you *would*
need support by the compiler.
for that gruesome array-thing you wouldn't.
Ah ok, now I get it. You want the compiler to automatically walk the array
if you do something.onbla; and onbla is an array. Well then you need to make
it a class that registers interfaces and then call it.
And yes, that is not at random "search a signature", but I never saw the
point of large scale use of that in non trivial programs anyway. Confuses more
than it solves.
I agree that for language use ref counted interfaces are useless. It is one
of my gripes with Delphi.
It is a necessity for COM, in a GC'ed system, they would only need to have _AddRef and _Release each
called *once*.
Yes. But what does COM have to do with MY interfaces? I just want the
multiple inheritance angle, and couldn't care less about the memory
management (that is simply tied to objects and their normal ownership
relations)
I can't see a solution to those w/o a GC that doesn't stink horribly...
What? A different type of delegate and non ref counted interfaces? Somehow
you seem to list a lot of your favourite scripting language functionality,
and then decide the cure to it all is introducing a GC. I'm not following
you here.
I do not like scripting languages, I prefer static compilation.
Or are you one of those die-hards, who call Java, Mono and .Net scripting languages as well?
No. Though I'm a bit in dubio that method matching of types not linked
through compilation fits in my view of static compilation. For that recent
Delphi's with its for..in violates that.
Actually, if the GC would be the same in your FPC App and say a C-DLL, you could pass a reference to a
string or record to it, use it somewhere else, and when it really isn't referenced anymore (in the DLL
and your Code), it would be freed/reclaimed.
Yes, and if I had a tail, I could waggle it.
Yep, I knew this would come. ;-)
As a matter of fact, Mono is using Boehm as well. So if you modified the linked BoehmGc.pas to use the
one shipped with mono, you could do exactly what I've written above with Mono as well.
And all memory allocated in the native part wouldn't even need to be disposed manually, as it'd be
managed by the GC as well.
But there IS NO POINT in doing that. Even if I go Java/C# for some
productivity reason, please leave me my escape where I can mitigate some of
its downsides in unmanaged code.
There is only one reason I can imagine using a GC for in native code. For some reason you
have some serverside application where memleaks are hard to kill.
Usually because the business code is both complex and dynamic (e.g. changes
at runtime by dlloading packages etc) and possibly faulty.
The classic extreme example I always use is a MUD. A MUD? Yes, a MUD, the
game that is programmed while it is run and similar BBS games whose code
changes without being taken down over plugin interfaces over a small
resident "driver"
A more business like example I could imagine are some very large webapps.
But since there speed doesn't matter that much, I'd simply pick ASP.NET 2.0
.
- References:
- Delphi for XCode?
- From: Slagert
- Re: Delphi for XCode?
- From: Sean Cross
- Re: Delphi for XCode?
- From: Marco van de Voort
- Re: Delphi for XCode?
- From: Rudy Velthuis [TeamB]
- Re: Delphi for XCode?
- From: Brad White
- Re: Delphi for XCode?
- From: Rudy Velthuis [TeamB]
- Re: Delphi for XCode?
- From: Sean Cross
- Re: Delphi for XCode?
- From: Marco van de Voort
- Re: Delphi for XCode?
- From: Sean Cross
- Re: Delphi for XCode?
- From: Marco van de Voort
- Re: Delphi for XCode?
- From: Robert Giesecke
- Re: Delphi for XCode?
- From: Marco van de Voort
- Re: Delphi for XCode?
- From: Robert Giesecke
- Delphi for XCode?
- Prev by Date: Re: Delphi for XCode?
- Next by Date: Re: A great new idea!
- Previous by thread: Re: Delphi for XCode?
- Next by thread: Re: Delphi for XCode?
- Index(es):
Relevant Pages
|