« first day (3864 days earlier)      last day (1077 days later) » 
00:00 - 21:0021:00 - 00:00

9:00 PM
@LeviMorrison I think no. That's why I was thinking the final placeholder should be ..., so only f(?, 1) and f(?, 1, ...) are valid, where the former implies the latter.
Though f(?, 1) implying f(?, 1, ?) is probably fine too, but I prefer the one with ... I think.
 
(f(1, x: ?))(); // f(1, 0)
Fatal error: Uncaught Error: Named parameter $x overwrites previous argument in /opt/src/php-src/test.php:12
(that's F:)
 
I can't build your branch because of timelib_strndup.
/Users/levi.morrison/Projects/php/branch-master/ext/date/lib/parse_posix.c:75:9: error:
      implicit declaration of function 'timelib_strndup' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
        return timelib_strndup(begin, *ptr - begin);
@JoeWatkins To be clear, this is because of f(1, x: ?) and not because of the way I'm invoking next, right?
 
yes
 
@JoeWatkins Without reordering I'm not sure that can work.
No, never mind, was thinking about it wrong.
That's just an error with the definition. Maybe another reason to not have named args with placeholders?
 
$p2 = volume(y: 5, x: ?, z: ?);
can't resolve that, too many trailing undef slots, but we can't know if they were named or not
 
9:17 PM
Yeah, that makes a mess.
Should have been defined as volume(?, y: 5)
Or maybe volume(y: 5, ...)
A reason to have a separate trailing symbol.
So partials with named params have to be defined that way.
 
function f($a = 0, $b = 0, $c = 0, $d = 0) {
    var_dump(func_get_args());
}
$f = f(?, 1, ?);
$f(0, 2);
$f();
if we don't allow trailing placeholders, there's no way to fetch the default value ... but it makes the call consistent with the engine
 
@JoeWatkins Trailing placeholders should be implied up to the arg count of the prototype.
The user should not need to define them for that to work.
@JoeWatkins $f() there seems wrong, 3v4l.org/7HpRY/rfc#output
I'd expect the same as f(b: 1)
 
krakjoe@Fiji:/opt/src/php-src$ cat test.php
<?php

function f($a = 0, $b = 0, $c = 0, $d = 0) {
    var_dump(func_get_args());
}
$f = f(?, 1, ?);
$f(0, 2);
$f();
f(b: 1);
krakjoe@Fiji:/opt/src/php-src$ sapi/cli/php test.php
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(0)
}
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
 
What about $f = f(?, 1);?
 
9:33 PM
hmm. is there like a buoy one could throw me that would allow me to begin to understand what's the discussion about? I promise I do not intend to actually participate.
 
<?php

function f($a = 0, $b = 0, $c = 0, $d = 0) {
    var_dump(func_get_args());
}
$f = f(?, 1);
$f(0, 2);
$f();
krakjoe@Fiji:/opt/src/php-src$ sapi/cli/php test.php
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
placeholders restricted to one trailing
 
@JoeWatkins So there is a difference between f(?, 1) and f(?, 1, ?) to func_get_args() though?
Perhaps effectively ignore the last ? there, as it's technically unnecessary?
Should be able to ignore any trailing ? in fact.
So f(1, ?) makes a partial, but the ? is effectively ignored in the partial if that makes sense?
$f = f(?); $f(); would be an empty array for func_get_args
 
10:24 PM
Michaelmjp ・ *General Issues ・ #81043
 
krakjoe@Fiji:/opt/src/php-src$ cat test.php
<?php
function foo($a = 0) {
    var_dump(func_get_args());
}

foo();

$f = foo(?);
$f();

foo(1);

$f(1);
?>
krakjoe@Fiji:/opt/src/php-src$ sapi/cli/php test.php
array(0) {
}
array(0) {
}
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(1)
}
 
11:06 PM
@JoeWatkins Cool. Would you be able to conditionally allow foo(x: 'bound', ?)?
 
positional arguments can't follow named arguments
also, I dropped named placeholders ...
 
silly question, is there a performance hit when using a ZTS build instead of a NTS?
 
It's semi-position, depends on point of view, since it's really just marking it as a partial. foo(?, x: 'bound') is fine too.
 
@Trowski
<?php
function foo($bar, $baz, $qux) {
    var_dump(func_get_args());
}

$partial = foo(?, 2, ?);

try {
    $partial(1);
} catch (Error $ex) {
    printf("%s\n", $ex);
}

$partial = foo(?, 2);

try {
    $partial(1);
} catch (Error $ex) {
    printf("%s\n", $ex);
}

function bar($bar, $baz, $qux = 1) {
    var_dump(func_get_args());
}

$partial = bar(?, 2, ?);

try {
    $partial(1);
} catch (Error $ex) {
    printf("%s\n", $ex);
}

$partial = bar(?, 2);

try {
    $partial(1);
} catch (Error $ex) {
Error: no argument provided for qux in /opt/src/php-src/test.php:9
Stack trace:
#0 /opt/src/php-src/test.php(9): Closure->__invoke(1)
#1 {main}
ArgumentCountError: Too few arguments to function foo(), 2 passed and exactly 3 expected in /opt/src/php-src/test.php:2
Stack trace:
#0 /opt/src/php-src/test.php(17): foo(1, 2)
#1 /opt/src/php-src/test.php(17): Closure->__invoke(1)
#2 {main}
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(1)
}
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(2)
}
 
11:21 PM
@JoeWatkins LGTM. Do you get a syntax error now with a named arg and placeholder?
 
yes
 
I think that makes sense. We can then support it later if we want without BC concerns.
 
Just want to share some eyebleach with my friends reddit.com/r/aww/comments/nd53m4/… reddit.com/r/aww/comments/nd61rt/…
In case you need a break :)
 
@JoeWatkins Can func_get_args() be an empty array here 3v4l.org/NYAbN/rfc#output or is that not possible?
I'm not sure how much it really matters…
 
@Tiffany <3
 
11:30 PM
You'd have to treat the final placeholder as not existing I think.
 
krakjoe@Fiji:/opt/src/php-src$ cat test.php
<?php

function f(int $x = 0, int $y = 1, $z = 2)
{
    var_dump(func_get_args());
    var_dump($x, $y, $z);
}

$f = f(?);

$f();
krakjoe@Fiji:/opt/src/php-src$ sapi/cli/php test.php
array(0) {
}
int(0)
int(1)
int(2)
 
@JoeWatkins Wow, that was fast.
Ah, hadn't looked at the commits :)
3v4l is just behind
@JoeWatkins This should only have 2 args in the array I think.
 
you made a hole, you have to fill it or it will use the default, no default is error
 
You could say the same about the code above.
The final placeholder isn't necessary, so you can remove it.
f(?, 2) == f(?, 2, ?)
If you always drop the trailing ?, it should work both in the f(?) case and for f(?, 2, ?).
f(1, ?) would make a partial with no "holes," only trailing args.
 
11:46 PM
> You could say the same about the code above.
except only one, which we special case, because minimum to create partial ...
if it's not necessary for the call you want to make, don't include it, right ? each has defined behaviour ..
 
@JoeWatkins Sometimes it's required, like the f(1, ?) case
$f() is valid, but func_get_args() will have 2 array members.
I had suggested forbidding f(?, 2, ?) before, but I don't know if others agreed.
Pretty sure Crell did not.
Trailing ? are really only necessary in the f(?) case or binding only the leading params, such as f(1, ?). Otherwise they're meaningless, so why allow it?
 
00:00 - 21:0021:00 - 00:00

« first day (3864 days earlier)      last day (1077 days later) »