Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103742 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84194 invoked from network); 15 Jan 2019 14:31:52 -0000 Received: from unknown (HELO mail-it1-f177.google.com) (209.85.166.177) by pb1.pair.com with SMTP; 15 Jan 2019 14:31:52 -0000 Received: by mail-it1-f177.google.com with SMTP id m8so793451itk.0 for ; Tue, 15 Jan 2019 03:07:44 -0800 (PST) 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=tmz3TUI5qteLX+OdpmMOVjY18na5JVq1F9kDmjoQnCg=; b=B7E/308UgFFRXc2VChePKfbz6eWcmx1YoFBUebrUnSMVdRZRmqjwbRmagBDxDy4NCA QOHL9KuJa0yMT5mgrvIj/O0JvrpY9jGBEw1QFtBWrdHd2XmUps4CZKfxVXNIbrrUrjLx 8FPCvodNM3Y1aAnMEpLxd++6CIB4aGyZql4+kqusLm7oRb18F+S6ByQE2IdWehTwfyGi wZ6XZH8zak0cqkCWjgAPkN2ccE5jlyJm42ZBbSIOOW+DyKGjODxv9r4pXvKWYBVpjdZF akvl+rWOVKr3xvOc7pV093HQCWH9HHo20mIqNd5UrY5O1OD2/i/LCmJoTHsgu0mfUeCG rASQ== 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=tmz3TUI5qteLX+OdpmMOVjY18na5JVq1F9kDmjoQnCg=; b=SKDNKNkNmnOhIKc9IRi3HeHohlrjhqkmCgqUn/pr1yS8bAZg5n4wvMxq5Ksgd9Y/47 y1eO3bIK1/6P9R7Hin3GYbtY5sAieMCba2+ApD3K8Gpl8bcyAq4iuEV+UWL7dU5bg4gF qMAoZAbbWr9r8ctASLR+8SDpL201Uj6BOE7mloFmIs5yQEd3L69TwUCzjdVos8QRyKxJ GArH2rCxG9llu/RAu0ZzhdE7IaQJ2fack7R7iMdTziaOuH/a/xJZsLVfRo2G+zINmN1I +Q7zb8jxGSs9GI0HW4cHLavG5pvb46IHQkycKgYX7FZnjhHh4EOpHOc/43n1Vo3z7eeP VAwg== X-Gm-Message-State: AJcUuke3toJWWQ3zXd2OZfdqnG/5KO6axvnc8xvNhAbev8+sZsP/4mRr Yc3rpa5j1vFEC7OmJLs/JRwJJRCLcArzuIR5wuA= X-Google-Smtp-Source: ALg8bN7Gd74CGdKOz5d91DG5VYx5VfLr0LYAO8oqfdvzl+zGk2qnug0aRKCxgpVP/3fuxbdK5+xhUGl16RrSi+FXXJo= X-Received: by 2002:a24:750f:: with SMTP id y15mr1998679itc.177.1547550463922; Tue, 15 Jan 2019 03:07:43 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 15 Jan 2019 12:07:31 +0100 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000ac9a0f057f7d2bdb" Subject: Re: [PHP-DEV] [RFC] Reflection for references From: ocramius@gmail.com (Marco Pivetta) --000000000000ac9a0f057f7d2bdb Content-Type: text/plain; charset="UTF-8" On Tue, Jan 15, 2019 at 11:57 AM Nikita Popov wrote: > > * instead of `$ref1->getId() === $ref2->getId()`, `$ref1->matches($ref2)` >> or such. >> > * what are possible scenarios for getting the identifier as a primitive, >> and then storing it somewhere (like an array of reference identifiers)? >> > * There seems to be a lot of design around `ReflectionReference#getId()` >> to avoid leaking internal pointer information: can it be completely >> dropped, if we have `$ref1->matches($ref2)` instead? >> > > As Nicolas already wrote, the ID / Hash functionality is needed to allow > hashtable lookups. Having just matches() would require iterating over the > whole set of known references and comparison each and every one. With the > getId() API, it's just a single HT lookup. > > We could add $ref1->equals($ref2) as an *additional* convenience method, > but it would not replace the getId() API. > I'd say that if the indexing is a fairly common scenario (seems like it, coming from Nicolas, who is the most direct API consumer here), the `->matches()` isn't needed at all. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --000000000000ac9a0f057f7d2bdb--