« first day (1662 days earlier)      last day (3286 days later) » 

6:00 PM
@Rican7 if it is random you might get the same id
isnt 1..2..3 good enough?
or sha($i) .. or etc?
 
uniqid will work for that. The only concern is the collisions when using it multiple times per-request. It is based on microtime, so between two requests it will probably be ok.... otherwise, you might have to go whole-hog and use a UUID
 
@RonniSkansing the counter won't exist for the next request
 
@bwoebi I guess the key is: does the closure bind the visibility in the place it was declared or ran?
Because if you support rebinding then it probably needs to be call time, right?
 
@LeviMorrison call-time.
 
@ChrisBaker yea, that's what I'm trying to stay away from. I don't need a UUID type 4, and I don't want to rely on another UUID/math lib just to provide some log context. :/
 
6:01 PM
@bwoebi ah really?
I thought it's based on the declaration (or rebinding)
 
@NikiC If you can rebind them I would expect that has to be the case.
Could be wrong.
It's one thing we'd want to pin down for sure.
 
But they're not implicitly rebound
 
@NikiC yeah… you can do it rebinding-time too…
 
@Rican7 There's still race condition concerns with anything time-based. You'd have to track previously-generated strings and regenerate on duplication... and still be vulnerable to race conditions if you wrote that record to a file or something.
UUID might be the only choice :/
 
Basically it should always be rebinding-time and the declaration can be considered the first rebind ;)
 
6:03 PM
but as laruence says… static:: won't work then as expected
 
well called_scope should be call-time, as the name says ^^
 
@Rican7 ah =] well pick a bad impl. like this unique_id() . sha1(mt_rand(~PHP_INT_MAX, PHP_INT_MAX))
 
or not, I'm not sure
 
I think visibility should be based on the scope it is bound to.
Maybe.
 
@RonniSkansing I'm honestly thinking of doing something like that...
 
6:06 PM
Late static binding sucks.
I hate this feature.
 
@Rican7 better put it in another sha1 then .. sha1(unique_id() . mt_rand ...
=p
lol
echo mt_rand(~PHP_INT_MAX, PHP_INT_MAX);
0
on first try
 
haha, dammit
 
actually quite often it lands on 0
 
dear god.... WTF?!
 
And now this @NikiC ^^
3v4l.org/pemNZ (self-constant inlining … look at the versions)
 
6:09 PM
@Rican7 "random"
 
[crying]
... tag fail
 
echo mt_rand(mt_rand(~PHP_INT_MAX, 0), PHP_INT_MAX);
fix
 
@bwoebi I remember working through this. It's actually defined in B's scope, not A's.
 
6:11 PM
@bwoebi That's the problem I was originally referring to
The fact that called_scope gets bound as scope there
 
You are calling B::test(), which means that you are defining it in B's scope, not A's.
 
@LeviMorrison nope, that's not how it works
self:: out to refer to A there
static:: would be B
 
@NikiC Nope.
 
@LeviMorrison the question is whether it's a defining or not. You can also say… We define the anon function at compile-time and bind it at instantiation-time (at run-time)
 
It only works correctly in PHP 7 because two different bugs cancel each other out :D
2
 
6:13 PM
@NikiC ^ that ^^
 
@NikiC You've just also described my work codebase.
 
In any case this is one of my points.
It needs reworked with clearly defined, documented semantics /cc @NikiC @bwoebi
 
Like your mom.
Sorry, had to, it is in my contract.
 
@ChrisBaker No, mothers are clearly undefined…
 
@NikiC Another item: we should be able to get an unbound closure from a method.
Right now you can only get a bound one.
 
6:17 PM
@LeviMorrison isn't that what static is for? Not having a $this binding?
 
@NikiC Oh, I'm going to bind it later.
 
Or you mean unbound in the sense of not even having self?
 
It's still scoped; just not bound.
 
@NikiC like a bug and an antibug? wow
 
I posted a question on the mt_rand thing is anyone cares =] stackoverflow.com/questions/30060396/mt-rand-returns-0
 
6:21 PM
@RonniSkansing hehe
 
What do you do by adding ~ prior to the constant?
 
=]
@Jeff could as been a - instead
or actually
no
then it return 1
 
@Rican7 No need for ~PHP_INT_MAX, use PHP_INT_MIN
@Rican7 it's because the random number generator is 32-bit
 
@RonniSkansing shouldn't you use mt_getrandmax() instead of PHP_INT_MAX?
 
@LeviMorrison @bwoebi So this is how I think LSB should work: If there is $this the called_scope is get_class($this). If there is no $this (static closure) then: If the outer called_scope is instanceof the closure scope, use that, otherwise use the closure scope.
 
6:24 PM
I'm asking since I don't know what ~ does =)
 
it scales up to larger numbers, but I think it's using a 64-bit integer to do the scaling...
 
@NikiC Going to read this a few times. Needs examples for every case though.
 
@bwoebi no...
 
@marcio didnt know that one
 
I think that would be a good compromise between matching normal static:: behavior and not exposing any particularly weird cases like having static not be instanceof self
 
6:25 PM
I'm building a AST parser. Going from template to AST. But keeping context. So it not only has statements and expressions, but also literals and html elements
an html attribute can have children :-)
 
@NikiC "If the outer called_scope is instanceof the closure scope, use that, otherwise use the closure scope." … that sounds a bit inconsistent to me… too many variables.
 
@ircmaxell that won't be fun
you can insert PHP literally anywhere
 
so far, I have 3 stateful parsers that switch back and forth between each other
on the same input stream
@Andrea not PHP, twig syntax
 
Ah, ok :p
 
and managing 3 stateful parsers is... rather... UMMM... yeah, no...
 
6:27 PM
Well the manual explains all as usual
 
@ircmaxell I think that's a good idea. I've done that before and when I tried to smash everything into a single parser… god no.
 
well... "good idea"
 
It's one of the best things you can do ;-)
[in this case naturally…]
 
FWIW @ChrisBaker it looks like this is related
 
@ircmaxell I just hope that the parsers are separate and don't interact between each other apart from input and output
 
6:34 PM
@LeviMorrison @bwoebi Okay, had a logic error there. Instead: Use the called_scope and scope from definition time by default. If a rebind is done, use the given scope both for called_scope and scope
 
@bwoebi they do
they all share a common cursor, and go back and forth between them with internal states
 
@ircmaxell I'd like to see your code ^^
 
What is rebind anyway?
 
@LeviMorrison bindTo etc
 
No, I mean that.
I'm saying what exactly does a rebind mean?
 
6:36 PM
@LeviMorrison setting a different $this and scope
 
Is it possible for called_scope and scope to be different after a rebind?
 
@bwoebi no thanks :-P
 
yes
 
@LeviMorrison no
 
@ircmaxell I won't send you to hell for that code, I promise…
 
6:38 PM
no, it doesn't even work
 
@NikiC Consider this example: bugs.php.net/bug.php?id=68194
Based on your explanation I would expect that it errors.
Right is an instanceof Base, so Right's scope is used. Right cannot access Left.
Am I following you correctly?
 
@LeviMorrison sorry I was wrong there, it can differ
 
@NikiC When?
 
@LeviMorrison Right would be used as called_scope, which has no impact on visibility
The scope is still where the closure was declared
@LeviMorrison When rebinding I mean
 
@Andrea ... wat?
 
6:41 PM
@Rican7 oh, is this PHP 5?
nevermind :p
 
lol
forgetting the real world, are you? :P
 
@Rican7 There is no PHP but 7 (and @NikiC is its prophet)
7
 
lol
 
user895378
PHP7 is the one true PHP. Red R'hllor demands it.
 
@rdlowrey these permanent asoiaf references <3
 
user895378
6:46 PM
Always.
 
@rdlowrey even bases his release cycle for Aerys on asoiaf
2
 
user895378
lol
 
hey
 
user895378
That is funny. Me and GRRM are on the same release schedule.
 
@PeeHaa Back for a short while :)
 
6:53 PM
@rdlowrey stop that. PHP7 is the one true PHP. Don't compare it to Stannis the Usurper
 
user895378
Don't you ever say an unkind word about Stannis the Mannis!
 
@rdlowrey (yes, slice-wise releasing helper chapters and then after years the full book)
 
Anonymous
still not a single book is out on php7 yet.
 
user895378
@samaYo I hadn't considered this ...
 
user895378
Room 11 should collaborate on a php7 book or something.
 
Anonymous
7:00 PM
+1.
 
Anonymous
Compared with what happened to the php6 problem. I assumed atleast one php7 book would be out by now.
 
@rdlowrey the bearer of the fake Lightbringer
 
@ircmaxell Good to know that even after being out of the forum business for a decade, SMF is still managed by blithering idiots.
 
the rest of the thread just keeps getting better and better
 
You and I have vastly different definitions of "better"
 
7:07 PM
;-)
 
@LeviMorrison @bwoebi So I just committed this: github.com/php/php-src/commit/… Tell me if it's still wrong ^^
@ircmaxell It's been known to happen
 
lolwtf /me opens the source of the first hit when searching for "wordpress password plugin":
 
sure, but has happened less as of late
 
$this->encrypt_password( $password_protected_pwd ) == $pwd && $pwd != ''
 
o_O
 
7:15 PM
I'll let you figure out what encrypt does...
And that was only in the first 5 minutes of my "research" :P
 
@NikiC Hmm. Seems odd that called scope is stored on a closure.
It's that an environment detail?
 
Ooooh noice. I see they also have something called a "secure cookie"! Can't wait to poke a hole in that!
:P
 
@PeeHaa xor with an application-defined string?^^
 
@bwoebi If only :P
 
@PeeHaa return $input? :-D
 
7:18 PM
@PeeHaa Is it better or worse than RADICORE?
 
@LeviMorrison The idea here is basically: If the closure is not rebound, it should behave exactly as if you put the code of the closure directly in the method.
And for that we need to keep the called_scope of the point where the closure was instantiated
 
That doesn't seem like it is "called scope"
 
@LeviMorrison called scope == static
 
zend_function stores the defined scope, yes?
 
md5 all the way + loose comparison FTW
 
7:20 PM
@LeviMorrison yes
 
What could possibly go wrong?
 
@NikiC Why doesn't closure rebinding touch that?
 
@LeviMorrison touch what?
 
Essentially, why do we need to store called scope? Don't we just need bound scope and called scope is in the executor globals?
 
@PeeHaa So, better than RADICORE.
 
7:22 PM
@Charles You would need to remind me
 
@NikiC is self always the self of defining scope now?
 
@PeeHaa radicore.org. The download is behind a login wall despite the AGPL license. Working logins are on bugmenot.
It's horrifying
 
@bwoebi unless rebound
While previously self was the static of the defining scope in some cases ...
 
password: password
classy
 
I still don't see why the closure needs to have the "called scope".
Why is the executor global insufficient?
 
7:25 PM
@NikiC when rebound, is self the $newscope and static the scope of $newthis (params of Closure::bind) ?
 
@bwoebi yes
 
wow that download is slow
 
unless $newthis is null in which case static is self is $newscope
 
@PeeHaa It's worth the wait.
 
Are called_scope and this_ptr ever both used at the same time?
 
7:26 PM
@NikiC nice
 
@NikiC typo:
 
@NikiC and now I need to disable self-constant substitution in case of Closures, right?
 
$d =& $c; // $a, $b                                 -> zend_array_1(refcount=2, value=[])
          // $c, $d -> zend_reference_1(refcount=2) ---^
          // Note that all variables share the same zend_array, even though some are
          // PHP references and some aren't.
 
At a glance it seems they aren't.
 
^^ the zend_array_1 should have a refcount of 3, no?
 
7:27 PM
@bwoebi I'll do that, because we have the same problem in a bunch of places
 
a, b and zend_reference_1 ?
 
oh
@NikiC okay
 
@bwoebi We've had handling for traits (where self is different from the active_class_entry), but closures were conveniently forgotten nearly everywhere ^^
 
hehe
And now, can we please silently drop static closures?
 
@ircmaxell ah, yes
 
7:30 PM
@bwoebi They should have never existed.
 
@bwoebi I'll at least silently drop some of the rebinding restrictions
 
ok, just wanted to be sure I didn't miss something
really awesome writeup btw. I'm looking forward to part 2
 
@LeviMorrison that too.
 
@Charles Chrome already warns me that it is possibly malicious :P Chrome is smart it can recognize crap php projects in a zip
 
@NikiC or @bwoebi I still don't see why called scope is stored on the closure.
 
7:31 PM
@LeviMorrison where would you then store it?
 
Isn't it already an executor global?
 
@PeeHaa Nice! I wonder what's setting it off.
 
@LeviMorrison yes, upon definition. But not upon call-time, that may be in an totally other context…
 
:-)
 
7:33 PM
@Charles This file is not often downloaded...
 
@bwoebi "called scope" is the scope it is called in.
 
Not surprising in the least.
 
How is it ever different from what the currently executing scope is?
 
@ircmaxell yay!
 
7:34 PM
/me 's mouse button hovers over the kick-mute @bwoebi button
 
This is a disaster. I don't even know where to look at first sight
It's super secure!
 
I'm readying myself for downvotes: reddit.com/r/PHP/comments/34y6ys/…
 
@ircmaxell … and quickly leaves that position before clicking…
 
@PeeHaa There are a few places where classes are hidden, one of them does password manipulation... the other hilarious example is the database class. That's when I gave up.
 
Yeah I am reading that thing as we speak :P
 
7:36 PM
@bwoebi So when you call B::test the called scope is a zce of B, and the scope on the method is A (assuming A::test is defined on be and B::test is not defined and B extends A)
Correct?
 
@PeeHaa Be sure to check out the author's rants. They're glorious.
 
whoopsie broke the build
 
@NikiC Seems like we can store the zce in the this_ptr, can't we? When an object is present called_scope is the scope of the object, yes?
 
Ooooooooooooh. Now I remember!
Yeah I have picked this apart before
 
@LeviMorrison the scope is A. Just like you can't call a private method of B from A::test().
 
7:39 PM
I am still unsatisfied with the explanation of called_scope.
 
Jan 15 at 10:25, by PeeHaa
@SergeyTelshevsky Ooooooooh it's the radicore guy. That explains a lot
Bad memory bad
 
The $this pointer would be B, though. [if not static]
 
You have to know the scope that was called, and the scope that it is defined in.
 
@PeeHaa It's natural to block out traumatic memories.
 
Why is the former simply not in the executor globals?
 
7:39 PM
@LeviMorrison yes… hence two values to be stored.
 
True :P
 
That's what I don't understand.
 
@LeviMorrison because we need to access that information at other times too? It's only in EG() when B/A::test() is called.
 
@bwoebi When is that different?
 
@LeviMorrison github.com/php/php-src/commit/… here we access EG().
we need to store this, because EG(scope) won't be immutable…
 
7:43 PM
Give me an example of when they will be different.
 
@LeviMorrison each time you call a new method EG(scope) is updated???
 
It seems like to me zend_function should store both if closures need to.
 
@Charles He was also the guy who talked about audits on his codebase right?
Or was that another idiot?
 
@PeeHaa Perhaps, though if so I don't recall that rant.
 
I remember calling out somebody and that came up. I thought it was him. Not sure though
E_TOO_MANY_IDIOTS
6
My brain just cannot keep up with the stupidity in the community
It's having a hard time enough with my own stupidity
 
7:45 PM
@bwoebi Why don't we store the called scope on methods?
 
@LeviMorrison zend_function generally isn't supposed to be changed at run-time…
 
@bwoebi It wouldn't be.
 
phew… I'm a bit confused now ^^
 
When B inherits from A it copies the function and alters the copy's called scope.
 
@LeviMorrison there is no copying? The hashtable contains a pointer to the same function for all classes extending the defining one
 
7:52 PM
Right, I'm saying that should be changed.
In my opinion methods and closures should match because methods are just a special kind of closure.
 
Can someone please help me out with my question? :) stackoverflow.com/questions/30060944/…
 
@LeviMorrison well… then let's __invoke a method…
 
@bwoebi Not sure what you are saying here?
 
8:08 PM
@JoeWatkins thinking about the SAPI, here's an idea. Implement PSR7 in core. So when you start the server, it runs the configured php file, which calls register_http_handler(callable $handler). It runs it to the end, then stops. Then it waits for a request, and then calls the handler :-)
 
8:40 PM
@LeviMorrison I share this opinion.
 
@LeviMorrison I mean a Closure is a complete class. It even has its own method, like __invoke.
It's rather a special type of anon class than a method a special type of Closure
 
@bwoebi Do we have a type flag for zend_class_entry in zvals?
I know we store them in zvals; but do we have a way to discriminate at runtime or just ones that we know should always be zces?
 
@LeviMorrison IS_PTR probably.
but no, we don't have more context (what type of pointer exactly it is)
 
I would expect something like this would simplify a few things:
typedef struct _zend_closure {
        zend_object       std;
        zend_function     func;
} zend_closure;
And all the information a closure needs is pushed into zend_function.
And methods also store this info instead of retrieving it based on call syntax
Maybe not, though.
 
@LeviMorrison zend_function only has a zce pointer, no zend_object ptr
 
8:55 PM
@bwoebi Yes, I am aware.
I was thinking about this trade off.
It makes object instantiation more complicated but runtime simpler.
Unless the extra size kills performance by bloating cache or something I expect that this would be a good trade off.
I think it's worth trying at some point. As if I ever have the time to do this kind of experimentation ^^
 
And I'm not sure how it would affect internal functions.
 
Also, by the way… the zce of Closures is Closure ce…
so, there's no way to store that in zend_function
 
9:10 PM
@bwoebi Sure there is; it's just a pointer.
 
@LeviMorrison I just mean… the pointer is already used.
 
Not sure what you mean?
 
the pointer is already used by Closure zce
 
Maybe I misunderstood this statement:
11 mins ago, by bwoebi
Also, by the way… the zce of Closures is Closure ce…
 
@LeviMorrison the zce pointer in zend_function of Closure methods is the Closure ce.
 
9:13 PM
Okay; why is that problematic?
 
because it'd break e.g. ReflectionMethod
 
What do you mean by "closure ce"?
 
zend_ce_closure
 
I still don't see what the issue is?
It's just a zce
 
sigh…
 
9:17 PM
@bwoebi I'm not going to lie; I don't understand a lot of internals with regards to function calls of any kind.
 
@LeviMorrison yeah… sometimes the only thing which helps is trying yourself and searching why it fails… that involves a lot of reading code closely…
 
hi all
 
9:40 PM
Hello!
 

« first day (1662 days earlier)      last day (3286 days later) »