On Fri, November 3, 2006 1:06 pm, Ilia Alshanetsky wrote:
> As much as I like the concept I would prefer to hold it off until the
> next minor release or PHP6.

I can actually see a fair amount of merit in having a "strict" mode
with type hints raising this kind of error...

If you're prototyping something you intended to port to C, but wanted
the freedom in prototyping phase to play fast and loose with types,
but then wanted to transition to a "strict" mode in PHP before you
went whole-hog into C.

Or, for some applications, in some modules, I think it would make
sense to be able to declare a particular function as NOT accepting the
usual rules of type-juggling.

Or, in my own little theoretical world, perhaps, to allow only a
certain acceptance level of type-juggling, such as "1" -> 1 is okay,
but "1 banana" -> 1 is not okay.  Not that I'm under any illusion that
THAT level of type-hinting will pass muster... :-)

But, to some degree, the whole filtering extension is all about this
same Principle of what is or isn't acceptable input, focussed mostly
on user input.

Perhaps the filter extension can be employed at the function level,
somehow, to say that such and such a function will only accept a true
(int) or something that passes filter XYZ.

It's not something that should be on by default, but it's not a
completely merit-less feature to desire, by any means.

How to do it efficiently, as an extra option, in a meaningful way is
the issue.

I'm pretty sure the patch supplied isn't really going to be a viable
answer across the board, but it's a good place to start a discussion
of "What if..."

As I thought about this more, it seems like the type-juggling is
really super incredibly useful in two main situations for me:
Input data from HTTP, which is always text.
Data from the DB interfaces, which doesn't always come out in a nice
native form.
E.g. PostgreSQL booleans end up as 't' and 'f' string :-(

But if the new input filters auto-convert to the desired required
output data type, and if the DB functions were a bit more type-aware,
I'd actually LIKE the data-types to do an E_NOTICE if they were
type-juggling almost anything else.

I never want to type '1' in source and have it turn into 1 later on.

I *love* that PHP doesn't make my write a bunch of code to convert all
the HTTP text into meaningful data, mind you.

But if I have to do all this filtering stuff anyway, because of all
the [bleeps] out there, I'm losing on that front anyway.

Fix up the DB calls to return the right data-types across the board,
and I'm really left with no strong desire for automatic type-juggling.

Which sounds really weird to say, given how useful it's been to me the
past decade, but that's where I am today.

Not that I plan to run off and try some other language or anything, so
I guess I'm not feeling THAT strongly about this. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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

Reply via email to