Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86078 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10071 invoked from network); 30 Apr 2015 07:03:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2015 07:03:25 -0000 Authentication-Results: pb1.pair.com header.from=walterp@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=walterp@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: walterp@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wg0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:34422] helo=mail-wg0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/93-27026-DB3D1455 for ; Thu, 30 Apr 2015 03:03:25 -0400 Received: by wgso17 with SMTP id o17so51732908wgs.1 for ; Thu, 30 Apr 2015 00:03:22 -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=az2yiUW3V+n6bLi5hmgXPUg8sUMr/DNJBhaeUSDrUZY=; b=lqTW4gim2YfPM7M/eBkm2GHIAjmhDNI21c3ax6d1d0ek3FdFvuNqoYu63CFXemrE68 6ud6LbdmOpWFzzn0ruoR4aVO4OQDiGSWSRv2sUSjYizlLFs8uksjJDsiD03i6AlEkJh9 ebd1TaZjHQC9WRXMV/Yvr2B/xGEUHrFweBCBtl87eRNUde11NIKHGODABM3MPdTRik44 NprwTn77nS8KAJMGjN/9Daz0QSXL3dJDuh90xNML4v/d354uAYEGQ1FUECWUtI2lEIfn +cjwpfOMRLH4BwenCACBD7j1vaJiEcHV+4ne2M3tub6R1HxmCIjIOiV0So3Rw0EH2Cve bwJw== MIME-Version: 1.0 X-Received: by 10.195.17.232 with SMTP id gh8mr5336102wjd.145.1430377402206; Thu, 30 Apr 2015 00:03:22 -0700 (PDT) Received: by 10.27.227.11 with HTTP; Thu, 30 Apr 2015 00:03:22 -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 00:03:22 -0700 Message-ID: To: Yasuo Ohgaki Cc: Stanislav Malyshev , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e016817e0f411760514ebb0f8 Subject: Re: [PHP-DEV] Adding "numeric" type hint From: walterp@gmail.com (Walter Parker) --089e016817e0f411760514ebb0f8 Content-Type: text/plain; charset=UTF-8 On Wed, Apr 29, 2015 at 11:54 PM, Yasuo Ohgaki wrote: > 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 > > Great! A Class or RFC that defined types that mapped one to one to DB types sounds useful. But this is not the same thing as generic pseudo type that are little more that predefined regexs applied to strings (a.k.a the numeric type). Walter -- The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. -- Justice Louis D. Brandeis --089e016817e0f411760514ebb0f8--