Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32349 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20896 invoked by uid 1010); 16 Sep 2007 23:09:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 20875 invoked from network); 16 Sep 2007 23:09:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2007 23:09:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.163 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.163 mail4.netbeat.de Received: from [83.243.58.163] ([83.243.58.163:34230] helo=mail4.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0C/D4-23448-8A7BDE64 for ; Sun, 16 Sep 2007 19:09:32 -0400 Received: (qmail 10954 invoked by uid 507); 16 Sep 2007 23:05:23 -0000 Received: from unknown (HELO ?192.168.1.102?) (postmaster%schlueters.de@62.245.161.130) by mail4.netbeat.de with ESMTPA; 16 Sep 2007 23:05:23 -0000 To: Nuno Lopes Cc: Peter Brodersen , internals@lists.php.net In-Reply-To: <002201c7f894$1b236060$4001a8c0@pc07653> References: <001f01c7f6f0$dbcf5350$4001a8c0@pc07653> <002201c7f894$1b236060$4001a8c0@pc07653> Content-Type: text/plain Date: Mon, 17 Sep 2007 01:05:23 +0200 Message-ID: <1189983923.17667.24.camel@johannes.nop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-2.fc7) Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: RFC: mark functions as const for possible optimizations From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi Nuno, On Sun, 2007-09-16 at 20:02 +0100, Nuno Lopes wrote: > > >My proposal is the following: > > >some functions when fed with constant arguments always return a constant > > >value, too. e.g.: > > >strlen('abcd') === 4. > > > > I like the general idea. > > > > Would there be some caveats with stuff like this if it is possible to > > change the charset at runtime? > > > > I guess it is important to be aware of whether a function is affected > > by different settings (and if these settings can be changed at > > runtime) to conclude if a function really is deterministic at this > > level. > > uhm, damn, right. strlen() wasn't a good example.. my bad, sorry :S > Anyway, you got the idea :) Nothing wrong with strlen as far as I can tell: - In PHP 5 we only have binary strings so strlen() works independent from any charsets and encodings by just counting bytes. - In PHP 6 we know - assuming the parameter is a constant string - the encoding at compile time, therefore it could be used. The only edge-case I see is if somebody uses mbstring.func_overload and overwrites strlen() johannes