« first day (1586 days earlier)      last day (3374 days later) » 

5:01 PM
@Danack and @LeviMorrison would that suffice you (@Andrea's proposal with declare(strict_types=1) pinned to the first line, and int->float type generalization)?
if so, I'll fork the RFC and edit it up...
 
@ircmaxell shouldn't you mention it to Sara?
 
@Sara as well ^^
 
@ircmaxell Yes. It's also no longer a block level statement right?
 
posted on February 18, 2015 by kbironneau

/* by gulymaestro */

 
@Danack correct
 
5:09 PM
Marvellous.
 
If @LeviMorrison +1's, I'll move forward with RFC
 
I can't help but wonder if something simple is causing a loop problem with stackoverflow.com/questions/28580635/…
 
Did you do the int->float thing?
@ircmaxell ^
 
@FlorianMargaine yes
 
5:11 PM
@ToCode It almost certainly is. Have you tried stepping through it with a debugger?
 
@Danack I haven't tried a debugger, could you recommend one please?
 
@ToCode jetbrains.com/phpstorm it has a free trial, is free for students and open source projects.
And is easily worth its price if you don't qualify for the free version, for the productivity gains it gives.
 
PHPStorm is totally worth it
It even tells you how much time it has saved you with all the shortcuts you've taken
 
@Danack Thank you, I will give it a try
 
(translates well to "suit-knob" language)
 
5:15 PM
There is a video tutorial on how to use the debugger - youtube.com/watch?v=LUTolQw8K9A
 
@Danack thanks
 
@ircmaxell Am not sure. I still think reserving the types and not doing anything else for 7 is a good course of action.
 
@LeviMorrison I'm not targetting 7. I'm targetting whatever. If it passes, and the RM wants to pull it in 7, great. If it goes into 7.1, fine
 
@ircmaxell If the types aren't reserved it can't go into 7.1 because of BC breaks.
Hence why I think reserving the types is the best immediate course of action.
 
@LeviMorrison then whip up an RFC to reserve the types for 7.0... I don't want multiple voting options
 
5:17 PM
Even if we never add strict types I would prefer to reserve these words.
 
user895378
@LeviMorrison I agree. I think this needs to happen regardless.
 
(I know some would vote against this)
 
user895378
And it needs to happen for 7.
 
(Reserving words and doing nothing with them is no net gain, only BC pain)
 
Hmmmm... why did I miss github.com/stephens2424/php ?
 
user895378
5:18 PM
And they could always be "un-reserved" in the future. But once used they become a BC problem and you've boxed yourself in.
 
@rdlowrey You have more time than me; can you write an initial proposal?
 
@Ocramius awesome
 
I can still push it through Internals if you don't want to.
 
user895378
@LeviMorrison I'm not sure I really want to wade into the types RFC arena as a participant.
 
user895378
Lest I be added to the list of internals feature-blockers like @LeviMorrison ;)
 
5:20 PM
:)
 
user895378
And I already just committed to doing a Generator::getReturn() RFC too.
 
Hi , should I leard Python or Ruby on rails ? Which language has better scope ? I am PHP dev(I work mostly on frameworks ,cakePHP). Thanks.
 
@ircmaxell does has to be first stmt collide with namespace? it has to be the first one as well afaik
 
@beberlei it must come before the namespace
because namespace supports both ; syntax and {} syntax (you can have multiple namespaces in a single file)
 
a wild @beberlei. what makes you come here?
 
5:28 PM
@Gordon hi :) i heard you could chat here
 
ThW
:-)
 
@beberlei yes, yes indeed.
 
@ircmaxell Did you try how much faster recki compiles on php 7?
 
not yet
 
I wonder if in cases like Recki HHVM still has some clear advantage…?
 
5:38 PM
general compatibility
@NikiC thoughts on how to detect block mode in the compiler?
declare(strict_types=1) {}

foo();
 
@ircmaxell child[1] should be non-NULL if there's a block
 
even if it's empty?
 
Maybe a STMT_LIST with numChildren==0
 
@Sara wouldn't that also happen with an empty {}?
 
@ircmaxell That's when it /would/ happen, yes.
 
5:42 PM
@NikiC works
 
Sorry, what are you trying to detect?
 
so I pinned declare to be the first op
but also want to disallow block mode
 
Right, but do you want to allow an empty {} or not?
 
no
 
@Sara nope
 
5:44 PM
So then as @nikiC said, check for null
 
You just threw me off by asking about "declare(strict_types=1) {}" and "even if its epty", implying you did want to check for that (for some weird reason)
But nevermind
 
Yeah, I wasn't sure if it always populated a list element or not (if it optimized it out)
 
In other news, Ze'ev and François have not-so-politely asked me to not put 0.4 forward since they have something they believe they have consensus on.
I don't think they do, but I'll enjoy the show
@ircmaxell It's the "{ ... }" that's the stmt_list, interrestingly enough
Well, that, and the implicit braces in the psuedomain
 
@Sara I'm making a .5, and pushing it out :-)
 
5:49 PM
@ircmaxell I'll get the popcorn
 
/me isn't planning on participating in the Drama. Just push it for discussion long enough to get it to vote
 
@ircmaxell 0.3 + top-level declare? Or...
fwiw, btw... call it 0.4 if you like. I don't own that number
 
+ top-level declare, and adding support for int->float generalization in strict mode
so number_format(50) will work
 
but not number_format("50")?
 
correct
 
5:50 PM
Today I had fun issue at work
 
/me looks for the Jiffy-Pop
 
"50" is a value, not a type
strict is about types
the fact that Zeev and Francois don't get that is not my concern
 
someone basicly did floor(0.58 * 100); made me lol alot
 
Nod
@Romni 57?
 
yea that will teach X not to float =] on crucial numbers
 
5:52 PM
@ircmaxell If you prevent "50 apples" in weak, then I maybe will accept it.
 
@bwoebi I'm out of it for now. Plenty of other plays in the ring.
 
@Sara was just a wrong ping, sorry ;-)
 
@bwoebi I'm 100% fine with that. Not sure how everyone else will be, since that's a BC break
 
/me makes some clarified butter to toss the solids onto the popcorn
 
@ircmaxell With this you even might get Zeev & Co. on board…
 
5:53 PM
@bwoebi it's also altering ZPP behavior
 
@ircmaxell yes, which isn't a bad thing, IMO.
 
zeev and rasmus both said they would be ok with fixing some of the wird conversions
 
then I'll do it
 
:-)
 
@ircmaxell +1
 
5:55 PM
@ircmaxell not so fast
To me it sounded like they'd be okay with it with @Sara's approach, where zpp behavior is not changed and the stricter rule for "42 apples" only applies if explicitly annotated in arginfo
 
which completely defeats the point of caller-driven strictness rules
 
@NikiC hmm, really? well… just ask them.
 
@bwoebi please no
 
@ircmaxell nah, I won't ask them.
and I meant you maybe should eventually ask them off-list
 
@ircmaxell So, while I am of course also in favor of not allowing "42 apples" even in weak mode, I think it may not be popular with some people and may compromise the RFC :/
@bwoebi *nit eventually != "eventuell" ;)
 
5:59 PM
but isnt arginfo actually what all userland code would do as well? explicit optin? now the internal api is forced to use typehints.
 
@NikiC
 
is there a way to get the returned array from a method in DOTNET class ? e.g $h = new DOTNET('assemblyname')->methodReturnsArray() i try it to var_dump it but it returns ... com_print_typeinfo breaks PHP :). other types are correctly returned like integers or strings
 
@bwoebi yes, user will use arginfo. Internal functions just don't use arginfo types in general (apart from rare exceptions) because we already check types in zpp. (And I'm referring to the existing type hints here, not just scalars)
I'm fine with having type hints in arginfo for internal functions for reflection purposes
 
@CodingInsane At the point where you though "Hey! I know! I'll use some .net assemblies in PHP" did you not also think "Hmmm, maybe I could do this more easily in C#"? :-P
 
6:04 PM
@NikiC yeah, that's no issue. But we really don't want to be forced to add arginfos everywhere… that's a task of impossibility.
 
@bwoebi exactly
adding types to arginfo is nice, but it shouldn't be a blocker for introducing scalar type hints
 
@DaveRandom i'm just playing around with DOTNET class but it's very buggy i made some hacks to get events working but now i'm stuck with return types
 
btw the PHP development process:
user image
4
 
@Danack :)
 
@Danack Isn't that the Agile process?
 
6:06 PM
@NikiC good point, I'll leave it to another RFC to change...
 
@Ocramius Theoretically no - you can see where you are on each step. Your current project however....
 
@CodingInsane My experience of playing with it was that it was very very very buggy and incredibly difficult to use even when it worked. Long story short: just use a language that is properly integrated with the CLR if you want to use .net. Or, whatever you are trying to do can be done in some other way using PHP. My $0.02.
 
@Danack haha
 
Don't let me put you off playing around, but just know that the peg is square and the hole is round and they don't work together.
 
@ircmaxell Suggestion: first try to fix zpp and only then scalar typehints. Then some people might be less opposed.
 
6:08 PM
 
Actually if it's PHP and .net, both peg and hole are irregular 73 sided shapes that look nothing like each other.
 
@ircmaxell Because the way it's now… weak is useless and strict is too strict for normal usage. And that way enough people will not accept that, I think.
 
strict is too strict for normal usage?
 
yes… well, if you still want some loose conversions like "12" => (int) 12.
and weak is useless, except that it does a cast.
 
@bwoebi Not allowing that is kind of the point of strict typing :)
 
6:11 PM
@DaveRandom i was trying to proof that PHP can do standalone applications :) but nevermind it will always be attached to a web server
 
@TheodoreBrown yes. But I mean, there's no way which would fit my needs.
 
@CodingInsane As in... GUI applications?
 
@bwoebi that defeats the entire point
 
@ircmaxell I don't say add it to strict…
I just mean weak is too weak. And strict isn't what I want. I have no issues which a strict mode existing… but the weak mode is not usable.
When I have weak typing, I want sane weak typing.
 
@bwoebi Would weak mode be acceptable to you if "42 apples" isn't allowed?
 
6:13 PM
yes, that's what I mean.
 
@DaveRandom yeah
 
@bwoebi It already produces a notice, at least.
 
@CodingInsane gtk.php.net - but for the love of Christ, don't. For the sake of your own sanity. It's theoretically possible to do what you are trying to do (people have done it, I've had to maintain the results) but it's a really bad idea.
 
@bwoebi elevate the notice to a warning ???
 
wait.
 
6:15 PM
@DaveRandom isn't this too old and not maintained anymore ?
 
@ircmaxell oh, this is a fail in hhvm? niiice
someone remind me why we aren't all using hhvm again?
ah right, compile times ^^
 
@NikiC Windows support :)
 
I can live without that ^^
 
@CodingInsane People have been doing some stuff with it lately, I believe it compiles against 5.6, go hang out in #php-gtk on freenode if you want to chat with the people who are doing that (seems to be pretty dead in there atm though)
 
6:18 PM
But I would be gobsmacked, frankly, if you could created anything approaching a working GUI application using DOTNET
 
@bwoebi :)
 
@NikiC I'd like such things prevented. Was confused with the apples…
 
@bwoebi Strict typing FTW
 
@TheodoreBrown but strpos("baaab", "b", "2") still should work.
That's all what I wish :s
 
@bwoebi I think you should just come over to the dark side...
 
6:21 PM
@NikiC not sure what the dark side is… :-)
 
@DaveRandom but i really achieved some good results events are now hooked up really nice that you can use them with closures
$form->onClick(function(){
	MessageBox::Show("clicked");
});
but i need to hack the DOTNET class from c to provide more features
and get return types to work
 
@bwoebi strict typing
"2" is a value of an integer, not a type of an integer
 
@CodingInsane Well... don't let me stop you... see you in a few years in an asylum somewhere :-P
 
@ircmaxell well, I don't care about the type I get passed in as long as I receive the correct type (exception: data formats which care about types)
 
you don't care about the type, as long as it's correct. Hence you care about the type?
 
6:25 PM
@DaveRandom lol, i will give it a little bit more tell i give up doing it :)
 
@ircmaxell Because some types have different semantics… (string and int and the bitwise not operator… sigh)
 
@bwoebi you're arguing for strict typing... I hope you realize that
 
@ircmaxell I want this to be possible: $number = getFromDB(...); strpos("baaab", "b", $number); … strpos internally will use it as an integer… and I don't care if I get a string or an int from the db.
 
@bwoebi Your getFromDB function should return the correct type.
 
if you know the DB will return you a valid integer, then cast it
but what happens if an idiot changes the column type to varchar and you get back "apple"
 
6:32 PM
@bwoebi "Strict typing......except where it's intuitively safe to just use implicit casts."
 
@ircmaxell exactly. In that case I want an exception. Instead of the cast silently working.
 
that's the entire point of a type system. It tells you that "you know what, there's a potential error here. I don't really think you meant to do this" at compile time. Where value type checking does the same thing at runtime. Where it's infinitely less useful
 
which is basically just an excuse for "I should validate what I get in"…
 
@ircmaxell Note that you can read it just with "but what happens if an idiot changes the column"
 
@bwoebi preciisely
 
6:37 PM
@ircmaxell there's just one headache here. mysql e.g. allows unsigned 32 bit ints. what do I do with them? They'd be auto-promoted on a 32 bit system to a float… and flawlessly work on a 64 bit system.
 
@bwoebi so you'd get transparent bugs with weak typing on 32 bit, but never be told about them.... And you're saying that's a good thing?
 
I don't know what I argue for anymore.
Last question… what happens with functions like ceil? you usually use them because you want an integer (you anyway cannot use them reasonably outside of precision range)… but they return a float.
(That's now just a question if everything was considered… I think I won't vote no on strict types anymore…)
 
well, why does ceil return a float?
 
> The return value of ceil() is still of type float as the value range of float is usually bigger than that of integer.
 
^ this.
 
6:44 PM
well then...
 
More proof that we need arbitrary size integers, but that's not the current discussion point.
 
yeah
or just sane function semantics rather than whatever someone felt at the time of creating this one
 
Also… a question about our division… It may return float or int. so… yeah… ($x + 1) / 2 !== $x / 2 + 1 / 2
 
@bwoebi if you hint on float, that's fine
 
but not on int.
 
6:47 PM
function div(int $a, int $b): float { return $a / $b; }
@bwoebi I think integer division in the special case and should be handled as such
function intdiv(int $a, int $b): int { return floor($a / $b); }
 
^ invalid
I'd like to have exact floats valid though… but it'd make static analysis harder.
 
because floor is retarted
 
I'm not sure on it.
@ircmaxell hmm?
 
floor() should return an int
just like ceil()
 
and round… yeah.
 
6:50 PM
Well, round can also return real floats...
 
IMO, these functions should return int|float. int if in range, else float.
 
round($foo, 2);
@bwoebi That'd be even worse.
You'd get an int sometimes and a float other times.
 
@Charles which is always accepted by a float typehint.
and if you get a float and want to pass it to an int typehint, it errors, just like we'd expect it.
 
@bwoebi yes.....numeric.
 
^^ that.
I don't mind float accepting int.
But we really could just use a "I don't care as long as it's not '12 bananas'" number hint.
 
6:52 PM
Which we probably don't have time to do right now - and probably couldn't given the level of obtuseness of some internals people. But it should be easier once scalars are there at all.
Or to put it this way. Weak scalar type hints don't break anything (?) and strict types may not be perfect, but are a good step forward, and make the outstanding problems be more solvable.
 
7:08 PM
I'm glad to see someone took up the cause of scalars
 
7:25 PM
namespace Symfony\Component\TypeChecking;

basicType nonNegativeInt extends PHP\types\int {
    public function isValid(int $value) {
        return $value >= 0;
   }
}

basicType PositiveInt extends nonNegativeInt {
    public function isValid(nonNegativeInt $value) {
        return $value != 0;
   }
}
oO
 
oh what did you dig up?
 
recent mail to list
 
oh interesting
 
nice indeed :P
except that they are set globally only
 
* This proposal is a compromise
* Internal Functions Like Ceil() return unexpected types
* "37" should be accepted for int types
* Integers Sould be accepted for strict float arguments
* Weak should error on "10 birds" style strings passed to int parameters
* int->float conversion isn't lossless
* int->float exception makes strict mode "flawed"
* static analysis is possible with weak hints
* should use exceptions instead of recoverable errors
what am I missing in terms of discussion points?
 
7:30 PM
'Sould'
 
I have it right in mine, typing fast here
 
@ircmaxell The last might be the only point of contention.
 
what other major issues have people brought up?
added "Nullable and Union types"
 
@ircmaxell There's also the numeric type suggestion.
@ircmaxell Problems with the original declare syntax.
 
yep - declare only top level and not required to be block.
 
7:39 PM
and use-strict
ok, any others?
 
for return types of internal functions, doesnt that require changing all the arginfo or how is this planned to go down?
 
PHP 4 Life
 
@beberlei they all return mixed today
tho that's a very good point
 
Is there anyone good with Database Design?
Need my schema looking over to make sure it is optimal
This is my first attempt at DB design
 
7:55 PM
@ircmaxell this will only be doable with sum/union types as fopen returns resource|false for example
 
@beberlei correct, and that's what I've done
not linked from RFC page yet (holding on that for a bit): wiki.php.net/rfc/scalar_type_hints_v5 @NikiC @bwoebi @LeviMorrison @Sara et al....
 

« first day (1586 days earlier)      last day (3374 days later) »