Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86074 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3678 invoked from network); 30 Apr 2015 06:49:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2015 06:49:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=walterp@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=walterp@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: walterp@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wg0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:34337] helo=mail-wg0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/32-27026-780D1455 for ; Thu, 30 Apr 2015 02:49:44 -0400 Received: by wgso17 with SMTP id o17so51416608wgs.1 for ; Wed, 29 Apr 2015 23:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=7baoSwy/P13ZB1rjp5oFvWTlZXeGMGhzSWDhXV7UtcQ=; b=fd15P+0lZYsqkvkDbh61ecU8tJL/0+Os6c6okagf/Qxga2pcwJlAm1snwNw9wN3KlZ h4s2MLOxt1vAqonTPxGULw630JojpnpYd0RAO3bkVoY4vNNv/TT5cAfIg5wGAt0fuivQ G2YwPhXHXGuB6TSpy4D+FZEozN2KWbj48QfcWbZZmBdBcHtTTt/Wgh2NyoDPfJaUU+HU 7MGJhNLD+EQzuZcpiWZ40KGQu9nNu4xe9YfnBWaTEzYsagsv8yVcpQ26V3oCtnZYS73k m9PDK7ccBC48cKk7ggN62O3dlmDVXha1K5FeUTVL4GSylnJHCeEFmNpeZaNv4YYqcUzy LH0g== MIME-Version: 1.0 X-Received: by 10.180.84.65 with SMTP id w1mr2599511wiy.20.1430376581149; Wed, 29 Apr 2015 23:49:41 -0700 (PDT) Received: by 10.27.227.11 with HTTP; Wed, 29 Apr 2015 23:49:41 -0700 (PDT) In-Reply-To: References: <55401F31.9030703@gmail.com> <55416849.9010808@gmail.com> <5541753D.5050908@gmail.com> <55419C0C.7020207@gmail.com> <5541C0E0.2080006@gmail.com> Date: Wed, 29 Apr 2015 23:49:41 -0700 Message-ID: To: Arvids Godjuks Cc: Stanislav Malyshev , Yasuo Ohgaki , Ryan Pallas , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d0444027403b90b0514eb8099 Subject: Re: [PHP-DEV] Adding "numeric" type hint From: walterp@gmail.com (Walter Parker) --f46d0444027403b90b0514eb8099 Content-Type: text/plain; charset=UTF-8 On Wed, Apr 29, 2015 at 11:40 PM, Arvids Godjuks wrote: > Stop trying to fix clever idiots from shooting themselves in the foot. The >> standard result from these actions is to make life a pain for regular or >> better programmers while only adding mild speed bumps to those clever >> idiots. >> >> Things like a numeric type will only encourage the clever idiots to write >> half broken code. >> > > Hello, just want to chip in. > > I use "INT UNSIGNED" for the MySQL primary keys since ages, because > negative primary keys make no sense. Well, mostly ID's for the records > actually can stay strings, but I will have to remember to use a string type > hint every time I pass a record ID. I expect a lot of times to forget that > and write int... > I was bitten a few times by the limits of 32 bit integer sizes too (moved > to a 64 bit server that time), but there are also unsigned 64 bit integers > that can and will be used in math operations and passed around. And we > don't have the "unsigned int". > > Okay, we have GMP. I will have to use it. But let me just ask - if I work > with a DB handling 64 bit integers (all I know handle them) or use a > DECIMAL field - automaticly use GMP then? Oh gosh.... > > Arvids. > I think you point out an interesting problem. It sounds like you designed the DB in isolation from the languages that would use it and then discovered after the fact that using the entire space (because it sounds like a good idea in isolation) can make life tough. Using a signed int would have only reduced your space by half. In many cases, it you need that extra space, you need more than twice and the difference between signed and unsigned is not relevant. If the code and DB are matched, then you don't have these problem. I'd suggest we make sure that we fix it in the right location (I don't think a numeric type is the right location). Walter -- The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. -- Justice Louis D. Brandeis --f46d0444027403b90b0514eb8099--