Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105358 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12092 invoked from network); 23 Apr 2019 16:51:01 -0000 Received: from unknown (HELO mail-io1-f46.google.com) (209.85.166.46) by pb1.pair.com with SMTP; 23 Apr 2019 16:51:01 -0000 Received: by mail-io1-f46.google.com with SMTP id c3so5105214iok.6 for ; Tue, 23 Apr 2019 06:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+MxxtYDXrhA6lqLcLa8fFwBd2LQvDopZHZ18UPZGMD0=; b=b17nAvJmIPkkjCcUoMXyCF4eVIfiHCQlD1ip7JWbHfWSIs/kSdTSoCyN45Ph+xtTP7 TOctUluMeAvK0qTUSLOJnhNJV6yXvLG2pCWx1Ta9H5iZHtATi3dRWtUnIFsU7KfZNJgv wFh7v/f/O+51kte7QuWigc4nZ+TZIml/i9phgGg+Zre3UhKZsTDulyLoPQL8ATVulMQ3 tcz4Q9L90mpErQXQ+umbwWRC1+oLuFklJ+5w79yfeOs9roPb8v1ATqrcY0oVboUrDaU7 /matmjoLUaE2GLLVeLAjH2HagKUTWl+p3Df1ZTdiQx3mbwk5+yEGfAFYx1TcpVrVP/c8 G+ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+MxxtYDXrhA6lqLcLa8fFwBd2LQvDopZHZ18UPZGMD0=; b=bDVKw//teidGgtF6rGHUvg79oGnNr5AwH4pbFuroiyuJiQKg0hZHfmZjyWelLplrhm +HDY6LbRQHThO1gYsaSQtYwtzI8bvRYwpYfnuHOOVmQhVnJEDVz2aeAn8Yb4DA4oxgvi 0sbW/m373Nt34N1ayZK7EfcG8Po2Ii4bKINrvwM7ElF3Ym1bsYnFu4QwGSlPLQD8MlMb 8RK8hxvhVNEMgSK+ecHEk/iEnNtKOvNClfPiBQeA8rgF3sTteezyHNMxHf+JkPTkP/Dc TM0fk8pPyeAGIV8ymlhP295SyLCdgVIQqd6KLFABlysECJ1D2y21I3CudCizHMR1Pi3I tO2A== X-Gm-Message-State: APjAAAXIKVTTTpfqZbTi/ZYIjtMl88WrZWttSLtXElK08sjeCK/b+G5z FKIFprNZwVFG9Lvg3jfy22CuRi/vz9+5KtP31QA= X-Google-Smtp-Source: APXvYqwtaKtTZjnvx4RjxmwsnYP4NesJEicDPzWg8BRPKybiIb+RpQYMJvngFjb6oVayAzCAXxrDc7bX3iM67+rOTPc= X-Received: by 2002:a5e:a60c:: with SMTP id q12mr6118631ioi.174.1556027485117; Tue, 23 Apr 2019 06:51:25 -0700 (PDT) MIME-Version: 1.0 References: <9fee0f79-a77d-c0f1-ec24-efa4dd587f91@hristov.com> <5cbf15b2.1c69fb81.3128f.100cSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <5cbf15b2.1c69fb81.3128f.100cSMTPIN_ADDED_MISSING@mx.google.com> Date: Tue, 23 Apr 2019 15:51:12 +0200 Message-ID: To: Mark Randall Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000082e2ff058732e158" Subject: Re: [PHP-DEV] Object Type Casting Reloaded From: benjamin.morel@gmail.com (Benjamin Morel) --00000000000082e2ff058732e158 Content-Type: text/plain; charset="UTF-8" @Mark Randall > It keeps coming back to the feature we've all been praying to the PHP > Gods for... generics. > $x = cast($obj); I did not think about using generics for this, but indeed this could work. It's only reasonably verbose, easily implemented in userland, and should be usable both by static analysis tooling, and potentially by the VM and JIT for future optimizations. It just costs an extra function call vs. a single opcode, but overall I could be OK with this approach. I'm not sure why generics haven't yet gained traction though, so unless there's a hope to see them implemented soon, I'll keep focusing on this standalone feature for now! - Ben --00000000000082e2ff058732e158--