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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to