« first day (1704 days earlier)      last day (3262 days later) » 

10:00 PM
Why should we ping @Trowski ?
 
which @Trowski?
oh, there's only one @Trowski ˙ ͜ʟ˙
 
> Warning Internal error: wrong size calculation:
Is.....that a thing?
 
@Danack sounds like opcache?
 
Compiling PHP src from master today.....
 
@Danack Apparently it's the cool thing to do today :D
 
10:13 PM
Would you rather provide login or Strong Security and no Account?
 
10:41 PM
When Z_TYPE(zcontext) is equal to 0xC, what type is zcontext? or is something just borked?
 
Anonymous
Is there actually anything wrong with using references in php?
 
Anonymous
Like variable variables?
 
@samaYo Those are completely different things.
References are fine, having only an insignificant speed penalty. Variable variables are poor practice, and should only be used in rare circumstances.
 
Anonymous
@Trowski so, that's it? speed is the only issue with references?
 
@samaYo Pretty much yes, since it actually has to create a new zval.
 
10:47 PM
The problem with references is that they're hard to reason about - and having arrays suddenly be mutable when they usually aren't is surprising......and surprising is bad.
 
Anonymous
ahh.. I assumed they were bad, becuase they may cause confusion as it was with the case of variable variables.. @Trowski
 
Well, @Danack has a good point.
I really should ask what context you're using them in, because returning references from or passing references to functions can be bad.
 
Anonymous
Nah, just modifying an array value.
 
Anonymous
speaking of functions, is there anything wrong with using a cloure to return a single instance of a class ... like a singleton ... with static $var inside?
 
Can the entire array be overwritten?
 
Anonymous
10:52 PM
nah, just to change the values ...
 
hola
 
@samaYo I've used static inside closures, it's quite handy actually.
 
Anonymous
@Trowski example?
 
Anonymous
Also, if not for using references ... I have to use global $foo I figured, references may be the lesser of two evils ..
 
the only nearly reasonable use for references I can think of is when you need to return some result and you also need to inform status. Since you can't return multiple values:
function doSomethingWithSideEffect($somearg, &$status) {
    $result = tryToDoSomething();
    if($result) $status = true; else $status = false;
    return $result;
}

doSomethingWithSideEffect('blah', $status);
// but I wouldn't do it myself, it's just a use case captured from somewhere on github.
 
10:56 PM
@samaYo If those are your options, then I think there's some design issues.
@marcio Even that doesn't thrill me...
 
@Trowski yeaa, hence the "nearly reasonable", but indeed references are creepy no matter the intentions ^^
 
@marcio The only reasonable use of references in my opinion is with closures.
 
how? oh right, like when you need array_*($array, $callback) to modify the subject.
 
It's the only way to make a self referencing closure
$closure = function () use (&$closure) {
    // ...
    $closure();
}
 
heh, is it really necessary?
(nevermind what I said about the callback and subject, just use a loop instead).
 
11:03 PM
That file has a number of examples of using closures with references to wrap around local variables. Since the scope is limited it's much harder to get in trouble.
@marcio Fortunately using coroutines makes most of that unnecessary. :)
 
@Trowski then nothing justifies references.
 
@marcio I still stand by the self-referencing closure being sometimes useful... but that's about all I can think of.
 
11:20 PM
Is it normal you have to null out optional zvals when parsing e.g. :
zval    zcontext;
ZVAL_NULL(&zcontext); //without this, zcontext has random value after zpp
zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &zcontext);
 
11:32 PM
@Danack Yes. Yes it is.
Though you should probably do ZVAL_UNDEF(&zcontext); so you can disambiguate a passed NULL from a not-passed arg
If that matters to you
It's the same as in PHP5 when you'd have done:
zval *zcontext = NULL;
zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &zcontext);
 
I thought it was suppose to be a pointer to a zval pointer that was passed to zpp?
 
@Trowski Only if a value was actually passed
 
@Sara Otherwise the pointer is NULL, so you could just use if (zcontext) to determine if it was set, correct?
 
ta - not had to handle optional zvals before.
 
zval *zcontext;
zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &zcontext);
if (!zcontext) {
    // zcontext was not set
}
 
11:37 PM
@Trowski Right.
That's the PHP5 way
 
@Sara Oh, what's the PHP 7 way?
 
The PHP7 way is what @Danack posted
Then you'd do: if (Z_TYPE(zcontext) != IS_NULL) {
PHP7 got rid of a level of indirection pretty much throughout the entire runtime.
 
Is there a way to differentiate between the param not being set and null being passed?
 
@Trowski You can initialize it to IS_UNDEF rather than IS_NULL. If nothing is passed, it'll stay IS_UNDEF, if an explicit NULL is passed, it'll promote to IS_NULL
 
@Sara Ah, ok, sorry you said that before but now I understand, thank you.
I'm getting a memory leak under PHP 7 that I don't see under PHP 5. I'm a bit new to debugging C, how could I track that down?
 
11:48 PM
@Trowski valgrind php whateverscript.php
And hope it's in an obvious place...
 
I've never used valgrind before, any suggestions for a guide to using it?
 
It's reasonably obvious (if it finds the error) - otherwise the manual is pretty decent valgrind.org/docs/manual/mc-manual.html
 
@Trowski Are you building PHP with --enable-debug ? PHP is great at reporting per-request (emalloc) leaks.
 
@Sara Actually I'm building long-running CLI processes.
I can rebuild it with --enable-debug if that will help me there.
 
yes, it will ^^
 

« first day (1704 days earlier)      last day (3262 days later) »