On 06/04/2013, at 1:40 AM, Rasmus Schultz wrote:
>> why not make struct almost like a class except
>> that $this is a copy (on write) - modifying and returning $this would
>> be a new instance of that struct/class. That would give you
>> public/private/static/variables/methods/interfaces/..., but
> why not make struct almost like a class except
> that $this is a copy (on write) - modifying and returning $this would
> be a new instance of that struct/class. That would give you
> public/private/static/variables/methods/interfaces/..., but it would
> lead to another type.
As said, I don't kno
> On the other hand, I would just use an array. (without any "magic"
> like methods on structs, yes you would have to write plain functions
> and not use OOP like methods).
Yeah, that's what people are doing right now - the problem with that, is
you have the class-name referenced on every call, e.
> I imagine the implementation could be something along the lines of checking
> for the '__struct' key when somebody attempts to use method-call syntax on
> an array, invoking the appropriate method with $this referencing the array
> you were using.
>
> The rest of the time, a struct, for all inten
> On Fri, Apr 5, 2013 at 8:50 AM, Rasmus Schultz wrote:
> > See the "Structs Tutorial" at msdn for a brief summary of structs in C# -
> > http://msdn.microsoft.com/en-us/library/aa288471(v=vs.71).aspx
>
> Looking at that code sample, yes - that is more or less exactly what I had in
> mind.
>
> I
If structs were even somehow interchangeable with "real" arrays, that might
be a really useful side gain:
$white = new Color(1, 1, 1);
$red = $white->r; // it's a struct
$green = $white['r']; // it's an array
$type = $white['__struct']; // => 'Color'
$array = ['r'=>1, 'g'=>1, 'b'=>1, '__struct
> See the "Structs Tutorial" at msdn for a brief summary of structs in C# -
http://msdn.microsoft.com/en-us/library/aa288471(v=vs.71).aspx
Looking at that code sample, yes - that is more or less exactly what I had
in mind.
I take back my last remark - I don't think the similarity in syntax is
con
On 04/05/2013 09:31 AM, Madara Uchiha wrote:
After discussing things over the PHP chat on Stack Overflow, I
realized I misread and missed the point.
Good suggestion, you have my +1.
On Fri, Apr 5, 2013 at 11:01 AM, Richard Bradley
wrote:
On Thu, Apr 4, 2013 at 12:57 PM, Benjamin Eberlei wrote
After discussing things over the PHP chat on Stack Overflow, I
realized I misread and missed the point.
Good suggestion, you have my +1.
On Fri, Apr 5, 2013 at 11:01 AM, Richard Bradley
wrote:
>> On Thu, Apr 4, 2013 at 12:57 PM, Benjamin Eberlei wrote:
>>
>> >
>> > structs as in c# don't have me
> On Thu, Apr 4, 2013 at 12:57 PM, Benjamin Eberlei wrote:
>
> >
> > structs as in c# don't have methods, however DateTime has them. so
> > this doesn't work. What you can do is just pass all the data in the
> > constructor and then don't change it, and you have your value type that is
> > immutab
You're right, struct isn't the right word - "value" is probably more
accurate.
value Color
{
public $r = 1.0;
public $g = 1.0;
public $b = 1.0;
public function __construct($r, $g, $b)
{
$this->r = $r;
$this->g = $g;
$this->b = $b;
}
public func
2013/4/4 Madara Uchiha
> OOP is not a beginner's concept. I don't want to sacrifice good coding
> practices for a better learning curve.
>
>
This is interesting. Best practices from other languages, including C#,
Scala etc, have shown that some things are better represented by value
types. Even i
OOP is not a beginner's concept. I don't want to sacrifice good coding
practices for a better learning curve.
Also, a glance on the manual would reveal that the method returns the same
instance for chaining (which is also debatable, why do we even do that?)
On Apr 4, 2013 7:46 PM, "Rasmus Schultz"
Is it a really big feature if it's just syntactic sugar and internally
stored as an array? say:
struct Color
{
public $r = 1.0;
public $g = 1.0;
public $b = 1.0;
}
Stored internally this might be something like:
array('__type'=>'Color', 'r'=>1.0, 'g'=>1.0, 'b'=>1.0)
Have you worked
On Thu, 04 Apr 2013 19:13:54 +0400, Rasmus Schultz
wrote:
I've been pondering this issue for a while now, and I keep reaching the
same conclusion, so I'm going to just briefly share what I think.
In my opinion, the real issue is not poor design of the DateTime class -
it
works as you woul
-- Forwarded message --
From: dor.tchi...@gmail.com
Date: Apr 4, 2013 6:19 PM
Subject: Re: [PHP-DEV] a couple of thoughts on the DateTime type debate
To: Rasmus Schultz
Cc:
I really don't understand the problem. You have a DateTime instance, you
manipulate it as you see fit
16 matches
Mail list logo