Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86077 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7303 invoked from network); 30 Apr 2015 06:55:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2015 06:55:02 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:33255] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/F2-27026-5C1D1455 for ; Thu, 30 Apr 2015 02:55:01 -0400 Received: by oica37 with SMTP id a37so40921710oic.0 for ; Wed, 29 Apr 2015 23:54:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=8/981dINqt4CanfZe0FVEZ4GmqeThiXMq7HJ2/79Svo=; b=OZsnrlhhQX1znwBaS1/wjVfQdWLyFId7/tv/wiFYmuyCcRQmqtjdEZKpK2jZtJN12g 7xXVOTJOwwhQVVOosW98XBQGRo35XXhLgZjyP5N4r2wrR6bVOKbqVOIBHfthc5clWbJx LBtYiI6GpjJ7mhChNUR4e+MHR1F4Jhi+Vc4YAlBn32IC9loN3jhF1oavZLXy2YLWG40R aYrXvJg8AyEC7FdpbpP0Ae5PP01LAOAUwIZYpRlLEi39UciSN61JTEfOze0gG36jOTu+ hinku3dww1qo/k4ZxSA7twZE3Hn/nrFmuU2/iAs36rEixKHnos/emNy7eIh4O8blGbQU d3Yg== X-Received: by 10.60.78.72 with SMTP id z8mr2282919oew.13.1430376899258; Wed, 29 Apr 2015 23:54:59 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.202.104.196 with HTTP; Wed, 29 Apr 2015 23:54:18 -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: Thu, 30 Apr 2015 15:54:18 +0900 X-Google-Sender-Auth: TOPHMm-HCJqq5EMDpneaEv6TeGY Message-ID: To: Arvids Godjuks Cc: Walter Parker , Stanislav Malyshev , Ryan Pallas , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0111d7caf9ada30514eb92c7 Subject: Re: [PHP-DEV] Adding "numeric" type hint From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e0111d7caf9ada30514eb92c7 Content-Type: text/plain; charset=UTF-8 Hi Arvids, On Thu, Apr 30, 2015 at 3: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". > Use of unsigned int8 for ID makes sense almost always if database supports it. I may do such mistake even if I know I should use "string" (or "numeric") for record IDs once I start using type hints. 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.... > I'm planning to introduce type affinity like SQLite. Then appropriate types for the value may be used automatically/semi-automatically. It's good for both security and performance. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --089e0111d7caf9ada30514eb92c7--