Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79798 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57882 invoked from network); 18 Dec 2014 00:05:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Dec 2014 00:05:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:53622] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1F/22-43959-34A12945 for ; Wed, 17 Dec 2014 19:05:24 -0500 Received: by mail-ob0-f170.google.com with SMTP id wp18so7213225obc.1 for ; Wed, 17 Dec 2014 16:05:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=eI6/f9uv/32EpIQoh2MqrFjpgMnXt2ukqC7JdpeSBqM=; b=LAD8GgfDszv0vxj7WdlmBCGY3mzTs+LhycdobaXBxczZ6/nyOzSOKtOrDlTVWcMUTJ dbSbweTqUg6HeTBhyT/2xmC9x1fFOfO+2VKDY65M6PisAGM7SWwpvvMjLfmJ1a8sc2tm hb8Y4BFtXf75WTZntxRb7+eD52M3cGDADQ+U1ydGb3CHpkEdHV1n2y1YyxWVZy8r0Qae fErJqdDyGB/fBEQrAlsPH2f8Dd/sQikia9f99kZtg2s98OfZmON6ecT4b0vmD02Sd7Xp BKZ4qxtP5cTWAbQw1HYaagESaTShMy4i0HDsOd5f6eeg7bJSs2vbUoXHnG6M73Ccbir9 TXVA== MIME-Version: 1.0 X-Received: by 10.182.130.232 with SMTP id oh8mr28024038obb.49.1418861120752; Wed, 17 Dec 2014 16:05:20 -0800 (PST) Sender: morrison.levi@gmail.com Received: by 10.76.89.237 with HTTP; Wed, 17 Dec 2014 16:05:20 -0800 (PST) In-Reply-To: <5491FA53.3010107@gmail.com> References: <548FEE87.7020602@gmail.com> <5491B77A.4020004@gmail.com> <5491CE95.7060909@gmail.com> <5491FA53.3010107@gmail.com> Date: Wed, 17 Dec 2014 17:05:20 -0700 X-Google-Sender-Auth: _03t_PBvrEPbxtXwB5gWRDGcF0c Message-ID: To: Stanislav Malyshev Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: levim@php.net (Levi Morrison) >> Programmable hashes of objects should be external to the object anyway >> because eventually someone wants to store the same object in a >> different way in two different structures. > > That is the requirement that no language I can think of implements - > Java, Python, Ruby, C# all have programmatic hash method, and none of > them changes it for different structures. C++ commonly does this. You pass a "hash function" as a template or constructor argument and use that for the structure. Additionally, this allows you to easily support types that don't natively provide internal hashing functions (such as objects from a third party library). In this case, doing it like Java, C# et al is an example of most languages getting it wrong, not them getting it right.