Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102488 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99212 invoked from network); 27 Jun 2018 15:20:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2018 15:20:57 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.208.50 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.208.50 mail-ed1-f50.google.com Received: from [209.85.208.50] ([209.85.208.50:33133] helo=mail-ed1-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/CD-01794-85BA33B5 for ; Wed, 27 Jun 2018 11:20:57 -0400 Received: by mail-ed1-f50.google.com with SMTP id l23-v6so3337558edq.0 for ; Wed, 27 Jun 2018 08:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=CvfFlsiTIHyMW3QPKbw4URyO+tkH2RIluR69swgG/Ck=; b=dc9v5SKbMD43iVuwsGOj5KzA/EpCIn1s/iFpoS0wE/3ggmzOuqZFh9E1aQza2CVUEg XtCnL5oXmaxPMpXkeu1Ao9OVKxvn8Ncqi/5QS5whhAGtmz8pgxAWaq/kAksIl/tp+A6h GH3nMhPGe9mcUr27zhd+/pSgJnAdvJ00deOqInIpNNlKfAQv89lVKxG02K7ACFY+jSy0 QeT7zbKInMMEplArbz16PLWaJ8z36pGg5odmQ56WIaZZjTy7/24vJO1UxMBU01bJaXtY eAls+u1kO/16TXtS6bvkPVM4fhvgrjEmkq2S3XY8FJBQoL1Sa7jkYeUbh5L/d+eVQkYF 8wiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=CvfFlsiTIHyMW3QPKbw4URyO+tkH2RIluR69swgG/Ck=; b=r4VsiE8RLzLjAmyvlZhqY+4GDLEsKII2prPCpxGaaAnooMoO2armxt8J+fKag5D+M7 3nedFXDqg6LfnNAeNOy5D2horzmFJyaugb3AENGcIWUWUJC+HjCGtslXD0Tr3V+cdN7l cBD121j53owJqjCYseTxWdpqvYSzhrw4wWq0sCMru59XstQ93RrzB/vNWtDBJnffVDmW Ev0Jvbb+81RH00bXyRTzbZ2gTkgMtp4Nk312Saq4un2h0hhGesImzeszIyxpLYNvWjw/ Bj0fjXb0uruqQ40dX/NWw1WH35wVgjoQLhbz8/QN4jsZY0ksxhsm6nj8KDSl1Uhjh6Ts x4MA== X-Gm-Message-State: APt69E2IO0G7tCeOwBh7jGiD0ANZ8jhmEGUlMHXKZ+qZNReB6b2GRMMe mZaz/5H8vujluIsS3Leo8aT8C606VbknTkLuD8vXbQ== X-Google-Smtp-Source: AAOMgpftlWdDu7Lk6sGrpMfdubgYTz9/7rRron2ZQ5YlQK5MGyf/7xM0+SO/c1S1VpujkRIg71ocQrLCD9cnPyViCWM= X-Received: by 2002:a50:8143:: with SMTP id 61-v6mr6245221edc.100.1530112853355; Wed, 27 Jun 2018 08:20:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:8863:0:0:0:0:0 with HTTP; Wed, 27 Jun 2018 08:20:52 -0700 (PDT) In-Reply-To: References: Date: Wed, 27 Jun 2018 16:20:52 +0100 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="000000000000172fbd056fa129af" Subject: Re: [PHP-DEV] [RFC] User-defined object comparison From: rowan.collins@gmail.com (Rowan Collins) --000000000000172fbd056fa129af Content-Type: text/plain; charset="UTF-8" On 27 June 2018 at 14:30, Wes wrote: > not some class, only same comparator function. e.g. this is ok, as __equals > is the same for both classes > trait X{ function __equals($o){ ... } } > class A{ use X; } > class B{ use X; } > assert((new A) == (new B)); > What does "the same function" mean, though? The same text? The same entry in memory? In this example, the Trait will be copied into the class at compile time, so is not "the same function" in terms of internal representation. It may not even have the same code, since the magic contant __CLASS__ will be compiled to 'A' or 'B', never 'X'. Comparing by text doesn't seem that sensible; you could easily have two objects with "__compareTo($other) { return $this->value <=> $other-> value ; }" but that doesn't mean they should be comparable. The only meaningful constraint you could put on it is either "both objects are of the same class", or assert($other instance self) - i.e. compare against the same class or a sub-class. I think it's more straight-froward to always call the handler, and let the user decide which comparisons are computable. Regards, -- Rowan Collins [IMSoP] --000000000000172fbd056fa129af--