Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66985 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92319 invoked from network); 5 Apr 2013 14:01:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Apr 2013 14:01:20 -0000 Authentication-Results: pb1.pair.com header.from=alex@kazik.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=alex@kazik.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain kazik.de designates 209.85.160.44 as permitted sender) X-PHP-List-Original-Sender: alex@kazik.de X-Host-Fingerprint: 209.85.160.44 mail-pb0-f44.google.com Received: from [209.85.160.44] ([209.85.160.44:40599] helo=mail-pb0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 38/21-20511-F29DE515 for ; Fri, 05 Apr 2013 09:01:19 -0500 Received: by mail-pb0-f44.google.com with SMTP id wz12so2022560pbc.31 for ; Fri, 05 Apr 2013 07:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kazik.de; s=google; h=x-received:mime-version:sender:x-originating-ip:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to:cc :content-type; bh=44gbWZnGRPzjY+eZjzKEkA/TX+GefULgJCntYMukkVI=; b=ZvoI4h6sE954LTvKV0sfsKTVOsu+pZYM6wx1gqk3ANdNxeKaNlSOPpHOiFkrdVWh7w VX7UdAnzkgPGA8px9RhdSnKwJwRApOfPDQFWLDnrUuZQh8TWc+D76fzaCD3f6n3jlB0b mZIpbsKGXfnON5XuCPbWfITZSQEGJZKZdCLtI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:sender:x-originating-ip:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to:cc :content-type:x-gm-message-state; bh=44gbWZnGRPzjY+eZjzKEkA/TX+GefULgJCntYMukkVI=; b=cZWELZEO3Z7Qlj1WOYcqKYeqVAoQkCsbOq1GXPLllk44AsYos1KCMaGMCy9pi+6JZv d0QEcotAyBT0vJSlBxBraqRx/GI0g6dBgu+g8hKNLoBpFKgEu1ZWcxbKtx/iTMQ3HtGh agz5hULgmflTUXKdS5xN8+3+YkhxiGEDIxfSTdpPyHnb83rtxFMgZLab2VaPeg89SmNN Auie8RvywPXQXMyTHApkiIq2DAxY94VMgHubwykGaOnljAtMHuqfgD5gQDnkdjCPHoig nwUTI7IEIQXnJmeS0z6VQkPQqTKm6umMKY0TdQ9/q5V7BSixQ6WvDyWHIIGdVLN4+Rft wEKw== X-Received: by 10.68.254.227 with SMTP id al3mr15008811pbd.184.1365170475971; Fri, 05 Apr 2013 07:01:15 -0700 (PDT) MIME-Version: 1.0 Sender: alex@kazik.de Received: by 10.68.191.36 with HTTP; Fri, 5 Apr 2013 07:00:55 -0700 (PDT) X-Originating-IP: [212.8.208.194] In-Reply-To: References: Date: Fri, 5 Apr 2013 16:00:55 +0200 X-Google-Sender-Auth: H2KjvQP1JbmKXm0sCMpgRyQXlq8 Message-ID: To: Rasmus Schultz Cc: Richard Bradley , Benjamin Eberlei , PHP internals Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQmrKR7C+/HKUUXFw1RySY6m4u6Vj8LaEhgngx9eoqm1J79OI5o/pEfP7/XNWLFXkPFWQQPQ Subject: Re: [lists.php] Re: [PHP-DEV] a couple of thoughts on the DateTime type debate From: lists.php@tx0.eu (ALeX) > 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 intents and purposes, is just an > array. One thing I do not like about the "struct as array" is that you can create "invalid" structs, in classes you could have all variables private and check during set, but not here: "$array = ['r'=>1, 'b'=>'yes', '__struct'=>'Color'];". Hmm... just an thought: 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. Or use a keyword to the class, e.g. "autoclone class Color {...", and not the new name struct -> it would be clear that struct/classes use the same namespace. You maybe even could do "autoclone class DateTimeImmutable extends DateTime {}" to create the immutable version. (I see no reason why an "normal" class could not be extended into autoclone, but useless in most cases though) 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).