On 12 August 2016 at 11:25, Lester Caine <les...@lsces.co.uk> wrote:

> On 12/08/16 10:07, Christoph M. Becker wrote:
> >> > I'm thinking
> >> > $var->setConstraint()
> >> > $var->setEscape()
> >> > $var->setReadOnly()
> >> >
> >> > Rather than having to build 'reflections' classes to pull out data
> that
> >> > a simple $var->is_valid or echo $var will output a correctly escaped
> >> > piece of text.
> > Actually, this is already possible; just use objects.  E.g.
> >
> >   class Container {
> >     function __construct() {}
> >     function setConstraint() {}
> >     function setEscape() {}
> >     function setReadOnly() {}
> >     function isValid() {}
> >     function __toString() {}
> >   }
> >   $var = new Container($some_value);
>
> This has been the problem all along. There is no overriding reason to
> change what we already have, but ALL of the improvements currently being
> discussed MAY be better handled with a return to the basic model of a
> variable. If a variable is 'readonly' there is no need to worry about
> each variable.
>
>
Thanks for the ideas on this feature.

A few thoughts.
1. The RFC for this isn't a change - it's an addition. If it gets accepted
and implemented, you still would not have to change your code if you didn't
want to.
2. There are differing ways of using the language. Yours is not better -
merely different. So I would think a relevant question is: can the RFC in
point support your style of coding along with that of others. A critical
point is throwing exceptions on invalid data, which might be hard to handle.
3. Your assumption of secure intra-nets is questionable. Defense in depth
is what one should strive for.
4. I think your suggestions might conflate validation and sanitation -
these are not the same and cannot be handled as one

That said, I generally think that built-in methods that accept Callables
are a great way to go. It encourages reuse through modular composition -
and could likely be a neater way around the throw exception/return error
code issue. It's obviously doable from userland, but could probably be
improved if implemented in the language.

Regards
Peter


-- 
CV: careers.stackoverflow.com/peterlind
LinkedIn: plind
Twitter: kafe15

Reply via email to