Board index » delphi » Re: RAD Studio Roadmap Updated

Re: RAD Studio Roadmap Updated


2008-04-27 05:00:51 AM
delphi12
Mikko Laiho writes:
Quote

I must have missed discussions on anonymous methods as it is a
completely new thing to me. Unfortunately the statement in the roadmap
quoted below does not make me any wiser.

"Anonymous Methods, which enable the user to define a method in the
body of an expression while extending the lifetime of any captured
local declarations and assign the resulting method reference to a
location of method reference type."

Could somebody kindly explain it in a way which is less condensed and
easier to understand?
In C# and Java, you already have them. An example is seen here:
msdn2.microsoft.com/en-us/library/0yw3tz5k(VS.80).aspx
I guess it is a safe bet that Delphi's anonymous methods will have much
in common with C#'s anonymous methods.
--
Rudy Velthuis [TeamB] www.teamb.com
"Modern capitalism is not about free markets, it is about
building sufficient mass that the market gravitationally
collapses around you." -- Alisdair Meredith
 
 

Re: RAD Studio Roadmap Updated

Robert Giesecke writes:
Quote
Tiberion will have Generics
FWIW, the code name is Tiburón, the Spanish word for Shark, not
Tiberion, which sounds like some ancient Greek name. <g>
--
Rudy Velthuis [TeamB] www.teamb.com
"The world is a tragedy to those who feel, but a comedy to those
who think." -- Horace Walpole (1717-1797)
 

Re: RAD Studio Roadmap Updated

Delphinian writes:
Quote
>Like I said, I have hardly ever seen code where there was a need for
>multicasting, so I don't think it is such an important language
>feature. For the few situations where it might come in handy, there
>are other solutions.
See my reply (MVC).
Fine. Doesn't mean I have seen more code using it, now. It might come
in handy for MVC, but this principle is old enough to have existed
before multicast delegates, or delegates at all, existed.
--
Rudy Velthuis [TeamB] www.teamb.com
"Real punks help little old ladies across the street because
it shocks more people than if they spit on the sidewalk."
-- Unknown
 

Re: RAD Studio Roadmap Updated

Rudy Velthuis [TeamB] writes:
Quote
Delphinian writes:

>>Like I said, I have hardly ever seen code where there was a need for
>>multicasting, so I don't think it is such an important language
>>feature. For the few situations where it might come in handy, there
>>are other solutions.
>See my reply (MVC).

Fine. Doesn't mean I have seen more code using it, now. It might come
in handy for MVC, but this principle is old enough to have existed
before multicast delegates, or delegates at all, existed.
Delegates - combination code and contextual data pointers, aka closures
- have existed for a good long time. At least since the 50s and Lisp,
and implicitly in the Church lambda calculus before that (i.e. 1930s).
When you have a way of creating closures, writing a "combine" method
which wraps two closure calls into a single forwarding closure becomes
trivial.
-- Barry
--
barrkel.blogspot.com/
 

Re: RAD Studio Roadmap Updated

On Sun, 27 Apr 2008 02:37:23 +0100, Barry Kelly (CodeGear) writes:
Quote
When you have a way of creating closures, writing a "combine" method
which wraps two closure calls into a single forwarding closure becomes
trivial.
For a specific case yes but, AFAICS, there would be no way to write a
generic method to do this. I sure hope there would be a way.
(FWIW, I use multicast delegates all the time to reduce cohesion in my
code. I'd use them more often if they weren't so much work)
--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
 

Re: RAD Studio Roadmap Updated

Eric Grange writes:
Quote
>Sure it does, as long as they're not part of the same process.

err... the whole point of DLLs is being in the same process.
We're not talking about DLLs. We're talking about the de{*word*81}.
There's no reason why you can not have a 32 bit IDE launch a 64 bit
de{*word*81} as a separate process.
--
Mike Swaim
MD Anderson Division of Quantitative Sciences
XXXX@XXXXX.COM or XXXX@XXXXX.COM
 

Re: RAD Studio Roadmap Updated

Does Win32 implementation Allow Syntax Like that
Button1.OnClick := begin
ShowMessage(Inttostr(ExternalToMethodVar);
end;
What about the Lifetime of that closure object?
Who Controls IT?
Oxffff from Russia.
"Rudy Velthuis [TeamB]" <XXXX@XXXXX.COM>???????/???????? ?
???????? ?????????: news:XXXX@XXXXX.COM...
Quote
Mikko Laiho writes:

>
>I must have missed discussions on anonymous methods as it is a
>completely new thing to me. Unfortunately the statement in the roadmap
>quoted below does not make me any wiser.
>
>"Anonymous Methods, which enable the user to define a method in the
>body of an expression while extending the lifetime of any captured
>local declarations and assign the resulting method reference to a
>location of method reference type."
>
>Could somebody kindly explain it in a way which is less condensed and
>easier to understand?

In C# and Java, you already have them. An example is seen here:

msdn2.microsoft.com/en-us/library/0yw3tz5k(VS.80).aspx

I guess it is a safe bet that Delphi's anonymous methods will have much
in common with C#'s anonymous methods.
--
Rudy Velthuis [TeamB] www.teamb.com

"Modern capitalism is not about free markets, it is about
building sufficient mass that the market gravitationally
collapses around you." -- Alisdair Meredith
 

Re: RAD Studio Roadmap Updated

65536 writes:
Quote
Does Win32 implementation Allow Syntax Like that

Button1.OnClick := begin

ShowMessage(Inttostr(ExternalToMethodVar);

end;
I hope so. That is one of the beauties of such locally defined methods.

What about the Lifetime of that closure object?
I'm sure that if they really have some kind of closures, they'll find a
solution for the lifetime problem. They found one for strings and
dynamic arrays too.
--
Rudy Velthuis [TeamB] www.teamb.com
"640K ought to be enough for anybody."
-- Bill Gates (1955-), in 1981
 

Re: RAD Studio Roadmap Updated

It is unlikely.
Suppose the next operation
(OnClick):=nil;
There is no way to finalize closure object because TMethod is not finalized
i.e. have none of finalized members.
Only if you use some tricks manually
var Method:TMethod;
begin
Method:=Tmethod(OnClick);
Tobject(Method.Data).free;
end;
But it is very unsafe.
There is not guarantee that Data member of TMethod is an object. And no
RTTI for DATA member.
Does Implementation consist of some magic finalized wrappers(Custom
Variants, Interfaces)?
BUT!!! In that case programmer have to maintain Life for Wrapper object
Until there is no Ref to Closure object, i.e. determinate it.
"Rudy Velthuis [TeamB]" <XXXX@XXXXX.COM>???????/???????? ?
???????? ?????????: news:XXXX@XXXXX.COM...
Quote
65536 writes:

>Does Win32 implementation Allow Syntax Like that
>
>Button1.OnClick := begin
>
>ShowMessage(Inttostr(ExternalToMethodVar);
>
>end;

I hope so. That is one of the beauties of such locally defined methods.
>
>What about the Lifetime of that closure object?

I'm sure that if they really have some kind of closures, they'll find a
solution for the lifetime problem. They found one for strings and
dynamic arrays too.


--
Rudy Velthuis [TeamB] www.teamb.com

"640K ought to be enough for anybody."
-- Bill Gates (1955-), in 1981
 

Re: RAD Studio Roadmap Updated

John Kaster (CodeGear) writes:
Quote
Tony Caduto writes:

>One of the goals is connectivity, I'd love to see a PostgreSQL
>driver for DBexpress.

The more we can get dbExpress refactored, the easier additional drivers
become. The team is hard at work on far better code leveraging of the
dbExpress code.

Can't they reuse some of the code in the Kylix version of the driver, to
speed things along?
 

Re: RAD Studio Roadmap Updated

"Rudy Velthuis [TeamB]" <XXXX@XXXXX.COM>???????/???????? ?
???????? ?????????: news:XXXX@XXXXX.COM...
Quote
Then the closure is probably not a TMethod. <g>
So if Closure Object looks like
TClosureObject000=class
private
ExternalToMethodVar:DWORD
public
procedure Implementation(Sender: TObject);
begin
showmessage(inttostr(ExternalToMethodVar));
end;
end;
Or may be it looks a little efficient. Like
TClosureObject001=record
ExternalToMethodVar:DWORD
procedure Implementation(Sender: TObject);
begin
showmessage(inttostr(ExternalToMethodVar));
end;
end;
PClosureObject000=^TClosureObject001;
So the next sample is still not valid for Win32
Button1.OnClick := begin
ShowMessage(Inttostr(ExternalToMethodVar);
end;
May be Anonymous methods it is just the short form declaration of nested
procedures and functions?
 

Re: RAD Studio Roadmap Updated

Quote
"Rudy Velthuis [TeamB]">>>>Then the closure is probably not a TMethod.
<g>>>>So if Closure Object looks like>>>>TClosureObject000=class>>
private>>ExternalToMethodVar:DWORD>>public>>procedure
Implementation(Sender: TObject);>>begin>>
showmessage(inttostr(ExternalToMethodVar));>>end;>>end;>Look at
how this is done in C#
2.0:>www.thinkingms.com/pensieve/CommentView,guid,9fe42970-09e3-44e2-a4d0-32d63139351a.aspx>or:
tinyurl.com/6mluzf On .NET there is no need to count references
manually, because VES knows the type of slot in evaluation stack and CLR
has the introspection mechanism to process roots in managed heap
object,i.e. because of GC. Look at my implementation of C# Yield keyword
in Delphi on santonov.blogspot.com.>I could imagine they do something
similar in Delphi, but the closure>should probably be reference counted,
like strings, dynamic arrays or>interfaces. So, do you want to say that it
would be a new Type with its own copy semantic?Or may be Do you want to
say that It would be an ability to overload assign operator for object?
And what about deterministic way to destroy object and incompatibility
with numerous existing Applications in that case. As for me, I am still
thinking that there is no need for this new type. So, next syntax is
unlikely: Button1.onClick:= begin
Showmessage(CapturedVar) end;
 

Re: RAD Studio Roadmap Updated

Sergey Antonov aka oxffff writes:
Quote
On .NET there is no need to count references manually, because VES
what is VES?
Quote
knows the type of slot in evaluation stack and CLR has the
introspection mechanism to process roots in managed heap object, i.e.
because of GC.
I am aware of the fact that classes are automatically garbage collected
under .NET.
Quote
Look at my implementation of C# Yield keyword in Delphi on
santonov.blogspot.com.
Will do.
Anyway, instead of a class they could use something reference counted
in Delphi for Win32, but otherwise use the same mechanism: local
variables are not local, they become part of the class instance (or
whatever it is) and are accessed from there. Right?
--
Rudy Velthuis [TeamB] www.teamb.com
"I want to die in my sleep like my grandfather...
not screaming and yelling like the passengers in his car..."
-- bumper sticker
 

Re: RAD Studio Roadmap Updated

Andy Syms writes:
Quote
Arif, is that you? ;-)
LOL!
--
Rudy Velthuis [TeamB] www.teamb.com
"Cholesterol is your natural defence against excessive
circulation of {*word*76}, which can carry venoms, poisons and other
toxins around your body." -- Michael Warner, in bpot
 

Re: RAD Studio Roadmap Updated

Quote
what is VES?

Virtual Execution System (VES): This system implements and enforces the CTS
model. The VES is
responsible for loading and running programs written for the CLI. It
provides the services needed to execute
managed code and data using the metadata to connect separately generated
modules together at runtime. The
VES is also known as the Execution Engine.
Look for ECMA-335
Quote
Anyway, instead of a class they could use something reference counted
in Delphi for Win32, but otherwise use the same mechanism: local
variables are not local, they become part of the class instance (or
whatever it is) and are accessed from there. Right?
--
Suppose there is some reference counted heap allocated essence.
Let's process the next code
Button1.onlick:=begin
showmessage(ExternalVar)
end;
that is translated to something like this:
1. Alloc instance (Closure object)
_Reference_Counted_Essence.Allocate; ->Getmem(InstanceSize+HiddenSystemFields);
_Reference_Counted_Essence.Initialize(ExternalVar); ->
self.ExternalVar:=ExternalVar;
2. And ImplicitConversion
_Reference_Counted_Essence._Addref ->
Something Like InterlockedIncrement(P.refcnt);
TMethod(A).Data:=_Reference_Counted_Essence;
TMethod(A).Code:=_Reference_Counted_Essence.Compiler_generated_method_for_
showmessage
3. Assign A to Button1.onlick property.
Right?
And now question for one million dollars.
How have Closure object been notived after next operation
Button1.onlick:=nil.
Quote
Rudy Velthuis [TeamB] www.teamb.com

"I want to die in my sleep like my grandfather...
not screaming and yelling like the passengers in his car..."
-- bumper sticker