Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Stas Malyshev
Hi! i actually implemented this in userland, but its rather ugly: It is ugly because you try to have one class with two semantics. It is a mistake. If you remove this ambiguity it actually would be quite small. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (40

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Benjamin Eberlei
On Sun, 05 Dec 2010 10:29:29 -0800 Stas Malyshev wrote: > Hi! > > > I propose to allow to work with DateTime objects that are marked as > > immutable optionally. This means that all methods add, sub, modify, > > I think it's a bad idea, which would instantly break all the code that > assumes d

RE: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Jonathan Bond-Caron
On Sun Dec 5 12:44 PM, Benjamin Eberlei wrote: > > 1. Just create a DateTimeValue object that is immutable, not > optimizing PHP to handle it with efficient garbage collection. > 2. One step further, add a "static class DateTimeValue" like syntax > that creates an immutable class. > > Any ideas

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Pierre Joye
On Sun, Dec 5, 2010 at 7:02 PM, troels knak-nielsen wrote: > On Sun, Dec 5, 2010 at 6:44 PM, Benjamin Eberlei wrote: >> So currently preferred over my patch are two solutions: >> >> 1. Just create a DateTimeValue object that is immutable, not optimizing PHP >> to handle it with efficient garbage

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Stas Malyshev
Hi! I propose to allow to work with DateTime objects that are marked as immutable optionally. This means that all methods add, sub, modify, I think it's a bad idea, which would instantly break all the code that assumes different semantics. Yes, I noticed the word optional, however, the code

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread troels knak-nielsen
On Sun, Dec 5, 2010 at 6:44 PM, Benjamin Eberlei wrote: > So currently preferred over my patch are two solutions: > > 1. Just create a DateTimeValue object that is immutable, not optimizing PHP > to handle it with efficient garbage collection. > 2. One step further, add a "static class DateTimeVa

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Benjamin Eberlei
On Sun, 5 Dec 2010 08:18:46 -0800 Herman Radtke wrote: > > You don't need to know if the instance is immutable or not, since the > > current DateTime instances also return themselves for method chaining. So > > any code that looks like: > > > > $d = $d->modify("+1 hour"); > > > > would work no

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Herman Radtke
> You don't need to know if the instance is immutable or not, since the current > DateTime instances also return themselves for method chaining. So any code > that looks like: > > $d = $d->modify("+1 hour"); > > would work no matter mutable/immutable. This is still a bit strange though. > But st

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Benjamin Eberlei
Hey Larry, You don't need to know if the instance is immutable or not, since the current DateTime instances also return themselves for method chaining. So any code that looks like: $d = $d->modify("+1 hour"); would work no matter mutable/immutable. This is still a bit strange though. But stil

Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Larry Garfield
I'd love to have a Value Object version of DateTime, as its current behavior is quite annoying. However, making it a toggle on the existing class does not make sense to me. A function or method that gets called with a DateTime object then doesn't know if it is safe to modify or not, and if the