| View previous topic :: View next topic |
| Author |
Message |
Max Guest
|
Posted: Wed Sep 17, 2003 4:33 pm Post subject: Delphi 9 feature |
|
|
A wonderful Delphi 9 feature! Isn't it?
procedure MacroSample(APers1, APers2: TPerson);
macro
MyMacro(x)
APers1.##x := APers2.##x;
end;
begin
MyMacro(Name);
MyMacro(Firstname);
MyMacro(Age);
MyMacro(Children);
end;
|
|
| Back to top |
|
 |
Anders Ohlsson (Borland) Guest
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Wed Sep 17, 2003 6:13 pm Post subject: Re: Delphi 9 feature |
|
|
"Max" <nospam (AT) nospam (DOT) com> wrote
| Quote: | A wonderful Delphi 9 feature! Isn't it?
|
Useless since it's already doable in a much better way through RTTI.
|
|
| Back to top |
|
 |
Captain Jake Guest
|
Posted: Wed Sep 17, 2003 6:21 pm Post subject: Re: Delphi 9 feature |
|
|
In borland.public.delphi.non-technical, Alessandro Federici
<nomore (AT) spam (DOT) forme> wrote in message <3f68a2fa$1 (AT) newsgroups (DOT) borland.com>...
| Quote: | "Max" <nospam (AT) nospam (DOT) com> wrote in message
news:3f688cd1 (AT) newsgroups (DOT) borland.com...
A wonderful Delphi 9 feature! Isn't it?
Useless since it's already doable in a much better way through RTTI.
|
Oh puh-LEEZE.
RTTI in Delphi only works on PUBLISHED members (and it is messier than using
macros!), but when writing assignment functions, you often want to
assign public, protected or even private members.
|
|
| Back to top |
|
 |
John Kaster (Borland) Guest
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Wed Sep 17, 2003 7:22 pm Post subject: Re: Delphi 9 feature |
|
|
"Captain Jake" <johnj[nospam]@comcast.net> wrote
| Quote: | RTTI in Delphi only works on PUBLISHED members (and it is messier than
using
macros!)
|
Which is all he's doing anyways so my example is pertinent.
He's using a procedure and because of this only have access to public and
published stuff (the protected, accessible from inside the same unit is a
Delphi bug IMO so I won't cosider the case in which that procedure is
implemented in the unit of TPerson <G>).
| Quote: | but when writing assignment functions, you often want to assign public,
protected or even private members. |
published are public, so that covers it. Protected or private you don't
wanna set unless you don't care about breaking simple OO design rules. That
is exactly what properties are for.
--
Best regards,
Alessandro Federici
RemObjects Software, Inc.
http://www.remobjects.com
|
|
| Back to top |
|
 |
Dennis Landi Guest
|
Posted: Wed Sep 17, 2003 7:29 pm Post subject: Re: Delphi 9 feature |
|
|
"Captain Jake" <johnj[nospam]@comcast.net> wrote in message
| Quote: | Oh puh-LEEZE.
RTTI in Delphi only works on PUBLISHED members (and it is messier than
using
macros!), but when writing assignment functions, you often want to
assign public, protected or even private members.
|
Check out the {$M+} compiler directive and also from the Delphi Help:
DevGuide: Creating Custom Components
Storing and loading unpublished properties
By default, only published properties are loaded and saved with a component.
However, it is possible to load and save unpublished properties. This allows
you to have persistent properties that do not appear in the Object
Inspector. It also allows components to store and load property values that
Delphi does not know how to read or write because the value of the property
is too complex. For example, the TStrings object can't rely on Delphi's
automatic behavior to store and load the strings it represents and must use
the following mechanism.
You can save unpublished properties by adding code that tells Delphi how to
load and save your property's value.
To write your own code to load and save properties, use the following steps:
1 Create methods to store and load the property value.
2 Override the DefineProperties method, passing those methods to a filer
object.
|
|
| Back to top |
|
 |
Captain Jake Guest
|
Posted: Wed Sep 17, 2003 8:03 pm Post subject: Re: Delphi 9 feature |
|
|
In borland.public.delphi.non-technical, "John Kaster (Borland)"
<johnk (AT) borland (DOT) com> wrote in message <3f68b365$1 (AT) newsgroups (DOT) borland.com>...
| Quote: | Captain Jake wrote:
RTTI in Delphi only works on PUBLISHED members
Incorrect.
|
What? When did this change?
|
|
| Back to top |
|
 |
Captain Jake Guest
|
Posted: Wed Sep 17, 2003 8:09 pm Post subject: Re: Delphi 9 feature |
|
|
In borland.public.delphi.non-technical, Alessandro Federici
<nomore (AT) spam (DOT) forme> wrote in message <3f68b337$1 (AT) newsgroups (DOT) borland.com>...
| Quote: | Protected or private you don't
wanna set unless you don't care about breaking simple OO design rules. That
is exactly what properties are for.
|
Hmmm...I beg to differ. When I assign one object to another I am really just
dealing with memory allocation issues. I want two copies of the same thing,
but I don't want to worry about the first one being freed before I am done
with the second. In this case I want ALL the state to cross over to the new
object, but I don't necessarily want all those state variables exposed to
*other* units. The way I view it, an assignment doesn't just
clone the external interface but the current state of the object too.
|
|
| Back to top |
|
 |
Rudy Velthuis (TeamB) Guest
|
Posted: Wed Sep 17, 2003 8:12 pm Post subject: Re: Delphi 9 feature |
|
|
Captain Jake wrote:
| Quote: | In borland.public.delphi.non-technical, "John Kaster (Borland)"
[email]johnk (AT) borland (DOT) com[/email]> wrote in message
3f68b365$1 (AT) newsgroups (DOT) borland.com>... >Captain Jake wrote:
RTTI in Delphi only works on PUBLISHED members
Incorrect.
What? When did this change?
|
It also works on many types, like Integer or records containing string or
interfaces, etc. <g>
--
Rudy Velthuis (TeamB)
"I don't know anything about music. In my line you don't have to."
- Elvis Presley (1935-1977)
|
|
| Back to top |
|
 |
Captain Jake Guest
|
Posted: Wed Sep 17, 2003 8:54 pm Post subject: Re: Delphi 9 feature |
|
|
In borland.public.delphi.non-technical, "Yorai Aminov (TeamB)"
<yaminov (AT) delete_shorterpath (DOT) com> wrote in message
<c6lhmv8fkvfrrnua1et82qr0blrpqasgk2 (AT) 4ax (DOT) com>...
| Quote: | What? When did this change?
With SOAP.
|
So then I have this ability in D6?
|
|
| Back to top |
|
 |
Yorai Aminov (TeamB) Guest
|
Posted: Wed Sep 17, 2003 9:40 pm Post subject: Re: Delphi 9 feature |
|
|
On Wed, 17 Sep 2003 15:03:32 -0500, "Captain Jake"
<johnj[nospam]@comcast.net> wrote:
| Quote: | RTTI in Delphi only works on PUBLISHED members
Incorrect.
What? When did this change?
|
With SOAP.
---
Yorai Aminov (TeamB)
http://develop.shorterpath.com/yorai
(TeamB cannot answer questions received via email.)
|
|
| Back to top |
|
 |
Captain Jake Guest
|
Posted: Wed Sep 17, 2003 9:46 pm Post subject: Re: Delphi 9 feature |
|
|
In borland.public.delphi.non-technical, "Yorai Aminov (TeamB)"
<yaminov (AT) delete_shorterpath (DOT) com> wrote in message
<a8ohmv4tmq0f8hffs69a5iueub0u2ko79v (AT) 4ax (DOT) com>...
| Quote: | So then I have this ability in D6?
I think so. It's not what you think, though - RTTI was extended to
support interfaces.
|
I thought interfaces had no private or protected members.
|
|
| Back to top |
|
 |
Yorai Aminov (TeamB) Guest
|
Posted: Wed Sep 17, 2003 10:33 pm Post subject: Re: Delphi 9 feature |
|
|
On Wed, 17 Sep 2003 15:54:49 -0500, "Captain Jake"
<johnj[nospam]@comcast.net> wrote:
| Quote: | With SOAP.
So then I have this ability in D6?
|
I think so. It's not what you think, though - RTTI was extended to
support interfaces.
---
Yorai Aminov (TeamB)
http://develop.shorterpath.com/yorai
(TeamB cannot answer questions received via email.)
|
|
| Back to top |
|
 |
Jim Cooper Guest
|
Posted: Wed Sep 17, 2003 11:14 pm Post subject: Re: Delphi 9 feature |
|
|
| Quote: | Protected or private you don't wanna set unless you don't care about
breaking simple OO design rules.
|
It doesn't in an Assign though, because the Assign method is part of the
definition of the class. You're free to access private and protected
things. Sometimes you have to access a private field in an assignment to
you don't trigger a setter method.
| Quote: | That is exactly what properties are for.
|
Protected properties are useful things to have too - they aren't all
public.
Cheers,
Jim Cooper
____________________________________________
Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Tabdee Ltd http://www.tabdee.ltd.uk
TurboSync - Connecting Delphi with your Palm
____________________________________________
|
|
| Back to top |
|
 |
|