Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62164 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87867 invoked from network); 15 Aug 2012 07:57:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 07:57:42 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 209.85.215.170 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:48814] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/02-06007-5765B205 for ; Wed, 15 Aug 2012 03:57:42 -0400 Received: by eaao11 with SMTP id o11so364970eaa.29 for ; Wed, 15 Aug 2012 00:57:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:from:to:cc:references:subject:date:mime-version :content-type:content-transfer-encoding:x-priority:x-msmail-priority :x-mailer:x-mimeole:x-gm-message-state; bh=LvHVbINrPtDS8C4BOaMKTOcTNNo8aDv90FtBTMAF/z0=; b=XIXM13RAaTJYnJrSYS5RGSbqZYn/aEkYR3bhMbMzXW72ZJiwzDkoXFw1kIiaOTumfX Ws5NDQGMXqoZKZlAWoZLbQnnGaS4oRHoStHeR3PBPze+rF/28bMUsqC8ylvmpT7Re00H QIJuQ7giuXcuv6ERON2s5lWKsu3Sx08YKOvKU4AqMHrl+/EF1NOxLG70DzB/XyyMSFF0 sP9NV13Qstr6e4Vzb4aLnchaqji1EN+zg+0rhmlbEtZGr9fS0HPOpOR8mcH4OvZFLTQA sZn3oX7lO0qb5UKCsgHsogujQseCbiIe4aU+gFaX3xMNFx+xOD121FeSUhGcTFpkNyP2 s75g== Received: by 10.14.198.65 with SMTP id u41mr10175332een.22.1345017458647; Wed, 15 Aug 2012 00:57:38 -0700 (PDT) Received: from pc (95-42-66-13.btc-net.bg. [95.42.66.13]) by mx.google.com with ESMTPS id h42sm1956985eem.5.2012.08.15.00.57.36 (version=SSLv3 cipher=OTHER); Wed, 15 Aug 2012 00:57:37 -0700 (PDT) Message-ID: To: "Stas Malyshev" , "Anthony Ferrara" Cc: "Levi Morrison" , References: <502A86AA.2030203@sugarcrm.com> Date: Wed, 15 Aug 2012 10:57:34 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Gm-Message-State: ALoCoQkdlfAIIceL5m2OygRoCPyfLFl2iCx/9ixwKYx9XAiXADo0eI0QCoLtTdWxZpzeqPuwlL54 Subject: Re: [PHP-DEV] Inline typecasting / typehinting for classes and interfaces From: sv_forums@fmethod.com ("Stan Vass") > Hi! > >> I agree with you. The one case where this syntax may be very useful is if >> we want to implement class casting. So introduce a pair of magic methods > > I do not think we want to implement class casting. I'm not sure how > class casting even makes sense - if the object is of one class, how can > you just make it into another class by casting? If you mean "casting" > actually returns another object of different class, then just make a > method for that that returns that object, I do not see how obscuring the > purpose of this operation with unobvious syntax would help. The discussion is starting to drift very far from my original proposal. Instead of trying to guess what I mean, can't people just refer to my very simple definitive proposed behavior? My proposal is simple: behave as an inline type hint. The same type hints you have in arguments lists, but inline. The use case is "I want to make sure this value is of this type" and a side benefit is the IDE can know the variable is of this type too (for autocompletion purposes). Whether they'd be exposed with the cast syntax or otherwise isn't that important. Languages like ActionScript expose inline type validation both by "static typing" hints and by "casting". In both cases the operation simply validates the class can be seens as an instance of this class/interface. Stan