RE: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references)
| From: | Clint Priest | Date: | Tue, 24 Apr 2012 22:23:48 +0000 |
| Subject: | RE: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60297@lists.php.net to get a copy of this message | ||
Here is a copy of what Dennis had written to me regarding automatic implementations from C# (the
model):
> Originally, C# did not support automatically implemented properties.
> There are several reasons why they were added. The first reason, is that while the syntax for
> properties is the same as the syntax for member variables, there is still some subtle differences in
> behaviour that cannot be accounted for by properties. Here are some examples:
> - Variables may be used as input to out/ref arguments. Properties may not..
> - Properties may throw exceptions - variables will never do that.
> - Properties may have side effects or take a really long time to execute.
> Variables have no side effects and will always be as fast as can be expected for the given
> type.
> - Properties support different accessibility - variables do not
> - When using reflection the properties and fields are treated as different MemberTypes so are
> located differently (GetFields vs GetProperties for
example)
Some of these above example still apply (reflection, execution time), so the automatic
implementations may simply be there as a way for authors to indicate their intention to make them
execute code at a later time.
This suggestion below shortens the syntax even further.
-----Original Message-----
From: Stas Malyshev [mailto:smalyshev@sugarcrm.com]
Sent: Tuesday, April 24, 2012 12:11 PM
To: Benjamin Eberlei
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references)
Hi!
> would it be possible to add a second shorthand syntax to the complete
> automatic implementation?
>
> Examples:
>
> class TimePeriod
> {
> public $Hours {};
> public property $Hours;
> public $Hours {property};
> }
How it is different from just public $Hours and why one would need this?
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
--
PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php