Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66981 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82219 invoked from network); 5 Apr 2013 12:50:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Apr 2013 12:50:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.220.178 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.220.178 mail-vc0-f178.google.com Received: from [209.85.220.178] ([209.85.220.178:52693] helo=mail-vc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/74-57919-E88CE515 for ; Fri, 05 Apr 2013 07:50:23 -0500 Received: by mail-vc0-f178.google.com with SMTP id hz11so3155571vcb.23 for ; Fri, 05 Apr 2013 05:50:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=ceaM1Vd4keXOVJlwTlDq572WqxXteGEzQq/iNDKxtfI=; b=TbhEDlIj1L3w2S538cffnx6mI6ekoimm7omGz8Ai01Qk4y29hZgQT8gePJN2abnNEw 6JlAM7s0X8xhyfAkWPwLEio2L9KQnP/zMVbTxPKZESXJHgxcSnxRWp+06FyPkpn2pIMo T8INNG4vJPBF0pIRaDM9VGzOZ499YWEIxSQaDg0RlYEDCMyZtBzMVQtk1HFEaWiFmsnK 3JPnaP2X+8fbH8r6mo0F57vjys+YG1G8iOppR+6BPMH1DK6pClt6SUSHOnfF1GLga2vc KEqMFZJ/frgP+kGo3CE+4Y4UqDuDlsFlf3cNt7+ISHnznTVlssepoTsErsHRoWV/6p0x dzVg== MIME-Version: 1.0 X-Received: by 10.58.80.4 with SMTP id n4mr7911273vex.5.1365166220316; Fri, 05 Apr 2013 05:50:20 -0700 (PDT) Received: by 10.58.28.134 with HTTP; Fri, 5 Apr 2013 05:50:20 -0700 (PDT) In-Reply-To: References: Date: Fri, 5 Apr 2013 08:50:20 -0400 Message-ID: To: Richard Bradley Cc: Benjamin Eberlei , PHP internals Content-Type: multipart/alternative; boundary=047d7b5d62649f3cb004d99c87ea X-Gm-Message-State: ALoCoQlt1rEqNw9yLm8t1x9tl3hSce30pKy2/JO4YR4IOBzSvFfxxFFTWhrKbc6KZkgWtv4CZ1B8 Subject: Re: [PHP-DEV] a couple of thoughts on the DateTime type debate From: rasmus@mindplay.dk (Rasmus Schultz) --047d7b5d62649f3cb004d99c87ea Content-Type: text/plain; charset=ISO-8859-1 > 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 confusing; what is confusing, is the way it works now... because there are certain types that we just naturally think of as being values, not objects, even if they have object syntax. I don't know C very well, and I certainly don't know the PHP codebase very well, but do you think it's feasible to internally piggyback structs on arrays? If structs were even somehow interchangeable with "real" arrays, that might be a really useful side gain: On Fri, Apr 5, 2013 at 4:01 AM, Richard Bradley < Richard.Bradley@softwire.com> wrote: > > 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 immutable. > > > It just requires a bit self control. > > > > On 04 April 2013 23:59, Rasmus Schultz wrote: > > > > You're right, struct isn't the right word - "value" is probably more > accurate. > > Actually "structs" in C# can have methods. They are exactly classes with > value type semantics (i.e. pass-by-value, like arrays in PHP). > > I think "struct" would be an ideal name for this feature, as this proposal > matches the C# implementation very closely, and many people will be > familiar with that. > > 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 > > > > Richard Bradley > Tel : 020 7485 7500 ext 3230 | Fax : 020 7485 7575 > > softwire > Sunday Times Best Small Companies 2012 - 6th in the UK > Web : www.softwire.com | Addr : 325 Highgate Studios, 53-79 Highgate > Road, London NW5 1TL > Softwire Technology Limited. Registered in England no. 3824658. Registered > Office : 13 Station Road, London N3 2SB > > --047d7b5d62649f3cb004d99c87ea--