« first day (1465 days earlier)      last day (3488 days later) » 

9:00 PM
I actually discussed it with Sara at PHPNW briefly
 
@LeviMorrison We can instead revise it once and if enums make it.
No need to create dependencies where none exist.
Also, enums don't address the FC concern in any case
 
That creates a BC problem, though.
 
In any case, I don't think it's an important issue. Doing a version check is not particularly problematic.
 
I haven't been keeping track, what is the FC concern?
 
@AndreaFaulds If we change it before 7.0, it doesn't. And if you plan this for after 7.0 then it doesn't matter anyway.
 
9:02 PM
@ircmaxell I need to go check if defined() works on class constants.
If so then it's a smaller deal than you were making it out to be ^^
(I think)
Because you can then use constant("ReflectionType::IS_SCALAR") after a defined("ReflectionType::IS_SCALAR") check.
 
By the way...
 
still not "clean"
 
Why should IS_ARRAY even be a ReflectionType thing?
We should have these type constants as globals.
or, well, for use by other stuff
 
@LeviMorrison You don't need to use constant for that either.
 
I don't like that the convention seems to be to use arbitrary string names
 
9:04 PM
@NikiC sure you do
 
@ircmaxell Why?
 
nevermind
 
@AndreaFaulds Can you give me a specific instance of what you are talking about? Something outside of reflection?
 
It will be conditionally excecuted
 
/me goes back to work
 
9:04 PM
@LeviMorrison gettype and the like
 
You mean those horrible functions is_array() and friends?
 
is_array is horrible?
 
I use those all the time
 
Well, is_array() isn't so bad but is_int() really sucks.
 
9:05 PM
why?
 
Nobody has ever used is_int() correctly the first time.
 
/me is confused
 
It's always made sense to me...
is_int(1.0) // false
is_int(1) // true
is_int("1") // false
is_int(<anything that's not an int>) // false
 
9:07 PM
Speaking of casts...
@NikiC You know what... to_int should return NULL.
 
@AndreaFaulds lol
"to_int() should " . ["return NULL", "return false", "throw an exception"][time()%3]
@AndreaFaulds Is that --^ an accurate representation of your opinion on this matter? :P
 
@NikiC I keep changing my mind :/
Each has its upsides and downsides
 
@NikiC ["return NULL", "return false", "throw an exception", "kill your first born"][time()%4/4+2]
 
I mean, returning FALSE is convenient but it's also BAD, BAD, BAD
In the sense that
 
9:10 PM
@AndreaFaulds Well, I have a solution to this problem.
 
huh?
 
Who the hell relies on that?
relying on it being false so it'll cause the typehint to fail? ew
that's not really what typehints are for, right?
 
why?
 
"to_int() does {...} on failure. This behavior was chosen based on a fair dice roll."
 
Hah
Hmm.
So, stupid idea incoming
Return a special value object which casts to integer if it succeeded, or to nothing on failure
 
9:12 PM
Define "nothing".
 
@LeviMorrison Cast fails
 
I'm afraid of what this discussion will be on internals.
 
(int)to_int("") <== BANG!
(int)to_int(1) <== 1
 
ugh.
 
I don't think changing these functions would pass.
Even if what you proposed was better, I don't think this BC will pass.
 
9:13 PM
Changing these functions?
????
 
The is_* family.
 
Changing what?
Never proposed that.
 
@LeviMorrison this is a new API
to_* not is_*
 
PHP development: When you've painted yourself into a corner, build a new corner to paint yourself into. :)
 
Oops ^^
But again, I've already talked about this.
 
9:14 PM
Screw it... let's return FALSE.
 
Just create can_be_safely_cast_to_type($var, $type)
 
:D
 
If it pisses off the HHVM team, all the better. :p
 
By doing the cast for the user you create the 'what to do on error' situation.
 
SCREW IT, WE'LL DO IT LIVE
 
9:14 PM
"is_int() returns false on failure, in order to piss off the HHVM team"
5
 
If you don't do the cast for them then you don't have the error situation either.
 
So, next question:
Should it trim whitespace? I feel it should.
 
@AndreaFaulds Also, I have a bug I need to fix.
 
@LeviMorrison Oh?
 
@AndreaFaulds nop
 
9:18 PM
@NikiC did you see my blog post preview that I shared with you?
 
@AndreaFaulds If you do an inheritance check for covariance where the return type is the name of the class being defined it fails unless you use 'self'.
 
@NikiC Why not? I mean, trailing whitespace isn't unlikely for user input
 
@ircmaxell yes
 
thoughts?
 
@LeviMorrison Ooh. OK.
 
9:18 PM
@AndreaFaulds if you need trim, call trim. if you don't, don't. so simple ^^
 
Are no core functions ever going to throw?
 
@NikiC I... suppose it's not that bad.
to_int(trim($foo))
 
I'd say that's the most rational ^ Better than do_something($to_something); // don't worry, I'll just do things you might have forgotten to be safe
 
eih
 
Generally I think exceptions are bad. Most error conditions I would not consider to be exceptional.
 
9:22 PM
On the other hand...
@NikiC I'm not sure trimming whitespace hurts.
 
@ircmaxell As you might expect, I don't agree with most of it ^^
 
@AndreaFaulds If you don't want " 1" to convert then it does.
 
and it makes the kind of thing I do easier - handling user data in forms
 
@NikiC no? really?
 
@AndreaFaulds ... I can't replicate it, which worries me.
 
9:24 PM
@AndreaFaulds It hurts in that in that many cases do not need trimming and removing the trimming from a function that does it by default is a lot uglier than the reverse.
 
I know this is an issue. Sure hope I can find out what it is exactly
 
to_int($value, $flags = TRIM_WHITESPACE_PLEASE)
 
@LeviMorrison capitalisation?
 
Maybe.
 
@NikiC You have a point.
@DanLugg No.
 
9:25 PM
@AndreaFaulds Sorry, the pipe closed before I pushed through a TCP_SARCASM
 
@LeviMorrison What do you mean by can't replicate?
 
I know I have a bug in my return types implementation.
And I couldn't reproduce it just now.
It's related to that self case, but is different.
 
IMO to_int shouldn't trim whitespace. Composing a function trimmy_to_int() is trivial, and while you can compose it you can't really decompose to_int to non-trimming behavior.
 
@AndreaFaulds Trimming by default is what will lead us down the to_real_int() road ;)
 
@NikiC Yeah, sure.
I'll remove the trimming. It makes the function faster!... I think.
 
9:28 PM
Very considerate of you. The poor CPU ^^
 
@NikiC It's only a poor little Haswell, it can't cope!
 
I should add that to my justification for using constants instead of methods for ReflectionType.
"It's faster this way! Less method calls!"
 
Also, @NikiC... have you updated the spec for Uniform Variable Syntax?
Because you should and it's your responsibility, you wrote that RFC...
 
@LeviMorrison However, we could use this argument to argue that strings will be even faster ;)
 
Retrieving a constant and doing a case match on an int is slower than a string compare, you think?
 
9:30 PM
If the string is interned, yes.
 
@AndreaFaulds I have this bug too: irccloud.com/pastebin/lpSevx7c
self is definitely not helpful in the context of reflection.
Well, maybe it is, actually.
 
Hmm
It might not be clear to the user of reflection what class self refers to
Would help if PHP did it for you.
 
@AndreaFaulds not yet
 
@NikiC Please do so eventually :p
 
Eventually :P
 
9:48 PM
@NikiC OK, I made it cease to support trailing or leading whitespace
 
@AndreaFaulds Thanks!
@AndreaFaulds So are we just returning false?
 
Yeah
If HHVM's team is mad, they should fix their JIT :p
 
Please dont'
Please, please don't do the cast.
Just provide a way to know if it can be safely cast.
 
@LeviMorrison ...the function does that too.
I mean, if you want, you can do if (to_int($foo) !== FALSE) { ... }
 
Except it forces your error model
No, that's stupid
Dont' use mixed return types
 
9:57 PM
I'm sorry, PHP doesn't have scalar return types
Hack does. Hack is not PHP. Yet. :P
 
Yet...
 
@AndreaFaulds I know you are being tongue-in-cheek but I am not.
 
but yes, @LeviMorrison is right: why would it have a mixed return type?
 
I'm not being tongue-in-cheek. I am serious.
There is nothing wrong with mixed return types.
Returning FALSE on error is a long-standing PHP tradition
 
pretty much all is wrong with mixed return types :P
 
9:59 PM
@AndreaFaulds return false on failing to do an action...not so much for casting.
 
that's when I typically write 2 methods: can_to_int($int) and to_int($int)
 
@Danack Well, you need some error value.
 
an exception
(raised, not returned, because an error is not a value)
 

« first day (1465 days earlier)      last day (3488 days later) »