« first day (3865 days earlier)      last day (1065 days later) » 

12:25 AM
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(1, ?);

f(1, 2);

$f(2);
printf("-----------------\n");
f(1);

$f();
krakjoe@Fiji:/opt/src/php-src$ sapi/cli/php test.php
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(2)
}
int(1)
int(2)
int(2)
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(2)
}
int(1)
int(2)
int(2)
-----------------
array(1) {
  [0]=>
  int(1)
}
int(1)
int(1)
int(2)
array(1) {
 
Errm… that doesn't look quite right.
 
do I miss something ? looks like partial call behaviour matches internal ...
 
f(1, 2) has $x = 1, $y = 2, and $z = 2, should be $x = 1, $y = 1, $z = 2
Oh, sorry, was thinking it was $f.
Let me re-look
 
I wrote it bad, I put the internal call between the application and call site of partial ..
it looks right, right ?
 
Yes, looks right.
@JoeWatkins Thanks so much again for working on this and putting up with our bike shedding, I (and I'm sure everyone else) really appreciate it!
I'm heading out for a bit, but I'll pull the branch later and take it for a spin.
 
12:37 AM
cool
 
1:05 AM
I was off assembling a new grill today. :-) Where are we at this point?
It looks like we're still on a single symbol, ?, and under-supplying ? is fine, and tacking a ? on the end to create a partial that has no arguments still works. Am I reading the above correctly?
 
probably have a flick through tests ... in summary
we dropped named placeholders, they are just not worth the confusion, it's a syntax error now, so open to the future if anyone can ever figure it out ...
we disallowed trailing placeholders because they're meaningless
using a placeholder for an argument that has no default and is not supplied at call time is an error
not providing enough parameters at call time is an error
 
Disallowed trailing placeholders... how stringently? Does that preclude partialing a zero-argument function to make it easy to reference literally?
 
So
zero(?) OK
four(?) OK
four(?, ?) No?
four(1, 2, ?) OK
four(1, 2, ?, ?) No?
four(1, 2, 3, ?, ?) No
 
right
 
1:17 AM
And you can name-arg binding values, but not the ? itself.
 
right
 
Which means... any function can be partialed with whatev(?, foo: 1, bar: 2, baz: 3);
And then the order of any remaining args is still the same as in the original function, yes?
 
right
 
thinking-face.gif I think I'm good with that result. It seems to still nicely support all the use cases I care about. My one concern is it might feel weird for people that four(1, 2, ?, ?) isn't allowed, since you're then matching the number of args in the original function.
Default values inherit through as well, yes?
 
yeah
 
1:28 AM
Are we settled enough on that I can update the RFC and not rewrite it again? :-) Because this one is going to be invasive surgery.
And am I the only one concerned about "you can't actually specify as many arguments as the underlying function has"?
 
1:42 AM
if we're going to keep it simple, then ?, ? at the end of a function is meaningless, the second placeholder has no effect ...
meaningless leads to misleading, I think it's better this way ... people were very confused by levi repeating that F(?) and F(? ad-infinitum) were the same ... well now they're not, the more we can avoid meaningless syntax the less room there is for misunderstanding, that's the whole reason for removing named placeholders ...
 
2:02 AM
@Crell
<?php
function foo($one = 1, $two = 2, $three = 3) {
    var_dump(func_get_args());
}

$foo = foo(?); # On it's own, placeholder means 0 or more args

$foo();

$foo  = foo(?, 2, 3); # At the start means one arg

$foo(); # Filled by default, if no default error
$foo(5);

$foo = foo(1, ?, 3); # Mid-application, placeholder means 1 arg

$foo(); # Filled by default, if no default error
$foo(5);

$foo = foo(1, 2, ?); # On end means zero or more args

$foo(); # Filled by default, if no default error
that's quite easy to understand, and doesn't leave room to be mislead ...
CI is down for the next few hours while it does full builds, so I'm gonna get some sleep ...
 
@Ekin I really love it! Stream took almost 9 hours because I ran into a problem around hour 3. It sounds and feels amazing!
 
2:20 AM
@Crell Maybe we need a zoom call.
Too much see-sawing and I'm not sure the RFC authors are on the same page, ha.
Nikita's intuition looks like this (I think, he said little, so guessing a bit):
function f($x = 0, $y = 0) { return $x + $y; }
$g = f(y: ?, x: ?); // $g = fn ($y, $x) => f(y: $y, x: $x)
 
2:36 AM
we're not doing named placeholders
what he said was if we can't do reordering, he's rather not support named placeholders
and we can't do reordering ...
 
I don't like shipping a feature which doesn't work with other features.
 
then don't
 
I think there is a reasonable model for how it should work that isn't convoluted. Prior to named parameters, Paul's model actually made a lot of sense and was pretty simple, albeit not exactly what people thought at first
But we have named parameters now.
 
you can still use them, just not as placeholders ... I'm not wasting any more time on named placeholders ...
 
That's fine; you don't have to implement it. I'm just saying that we should at least spend time modeling how these features can work, and only after attempting that and not finding a solution, then go back to what we have and just forbid it.
Design work, not implementation work.
 
By itself it looks fine.
 
I have spent a bunch of time on it, it's a bit pointless coming up with models that can't work in the real world
@LeviMorrison doesn't need to be more complicated than that ... and that's what we have at the moment ...
and it addresses most of the concerns being raised over and over ...
some people just won't be happy until we use 6 tokens and have every obscure feature, I'd much rather ship something simple that we can make work in the real world ...
 
It's an excellent model and implementation prior to named parameters. I think it's important that we consider those, so I'm going to try. You don't have to implement it.
 
I don't think you're listening to me
it's a waste of time to try and model something you can't make work ... better to focus on arguing the case for things we can actually make work, and that don't have the rather large problem that they're totally impractical ...
@LeviMorrison you do understand the thing that makes this a waste of time, right ?
 
@JoeWatkins No, what?
 
2:59 AM
at the beginning of every function is epilogue, how the function is entered is not determined by arg info, it's determined by those first instructions, they're fixed in position and cannot be practically moved, we cannot copy bits of them, nor copy the functions instructions after them to another place ...
without the ability to rewrite the epilogue, it's actually impossible to reorder arguments, with everything the way it is today (up to and including code in mprotected shm) ...
 
(sorry, wouldn't it be the prologue, not the epilogue?)
 
now, that doesn't make it impossible to look like you've reordered the arguments, you can generate code and trampolines and mappings ... but that ruins everything ...
sorry, yeah, prologue ...
when I say there's no practical way to make it work, there really isn't ... not a practical approach that we could actually use... any approach would mean a rewrite of named parameters, and a hugely complicated implementation of partials, of the kind we would not vote in ...
I mean there are many other smaller problems, and I've spent time on all of them, and the big problem ... think about the only way to re-order arguments in userland, you have to do that much work on every application (that includes call time) ...
even the smaller problems present real difficulties ... at the moment, named parameters sent in order are not sent by name, so by application time (possibly as early as compile time) the name is lost, just changing that one detail would have a real effect on code not using the feature we're changing it for ...
~~possibly~~
thing was pestering me to finish typing ...
they're lost at compile time if the function being called is known, the name is not even part of code anywhere ...
you can determine their name from their position when they're not sent by name, like I said you can do mapping and generation and trampolines ... but you sacrifice all chance of simplicity ...
 
3:47 AM
Reordering in a partial declaration is not necessary at all IMO. But if somebody comes up with an implementation someday for using names with placeholders, the current implementation does not prevent supporting it in the future, so I see no reason to not move forward with what you have, as is.
 
they're partial calls, not partial functions, they're not declarations, that's the problem ...
but yeah, I think the 80% use case is easily covered ...
 
@JoeWatkins Ok, yeah, that's a better way to think about partials.
 
and it's not like named params are broken, you can still use named arguments ...
 
Being able to bind using named params is awesome.
Looks like there is no clean in the makefile to remove zend_language_parser.c and friends, is that right?
 
4:10 AM
yeah
the generation rules ought to make it pointless to remove those files, and a make clean might be followed by a release process ... and you need those files in release tarballs ...
 
Maybe it's macOS weirdness, but if I don't delete those manually it won't rebuild them.
@JoeWatkins This segfaults:
$callback = function (): void {
    var_dump(func_get_args());
};
$partial = $callback(?, 'value');
$partial();
Not exactly sure how you want to fix that. The partial is expecting an arg when it doesn't really need one.
Maybe error on the partial call?
if (arg > partial->func.common.num_args) {
	return "variadic";
}
Making that arg >= also sort of fixes it :D
 
4:32 AM
I done it, writing test
 
I was trying to decide when that would otherwise return "variadic." An actual variadic function shouldn't care about a param not being passed.
 
yeah there's no tests covering that
pushed fix for that ...
the error messages are not good, I'll extend them ...
 
Hmm… I think that will still segfault.
 
it doesn't, why do you think it should ?
 
$callback = function ($a): void {
    var_dump(func_get_args());
};

$partial = $callback(?, ?, 'value');

$partial(1);
Sorry, should have said "has the potential to still segfault."
 
4:41 AM
ha, I get nonsense
no argument provided for a
no wait, that's right
what do you get ?
 
Simple fix I think, arg == partial->func.common.num_args
Instead of !partial->func.common.num_args
That works for me then I get "no argument provided for argument #2"
 
that's not right, it's "a"
 
I provided an arg for $a, but not the second in the partial.
 
sorry I miscopied
yeah that works ...
we don't have good coverage I don't think, I'll start running with coverage data soon and improving ... the tests have become more of a part of the RFC and demos than actual tests ... but it saved me a bunch of time ...
 
I tried a bunch of weird things and that's the only one that failed.
 
4:46 AM
well the code is quite simple now, and reused ... it looks quite tidy at the moment ...
 
How are constructors handled now? Does it only make an object upon invocation?
Looks that way, if I understand the code around ZEND_APPLY_FACTORY
 
in zend_partial_apply near if (Z_TYPE_INFO(partial->This) & ZEND_APPLY_FACTORY) {
it allows the engine to destroy the initial object and creates factory from type, which call_magic executes on invocation ...
 
When are properties initialized on an object?
 
during new, but right now they'll only be constants ... nikita already noticed interactions with new in initializers, we're not sure if his problem or mine basically ...
it can be solved anyway, we just need space for a flag somewhere ...
we want to not waste the initial object, but it doesn't look like a huge problem if we do, for now ...
 
5:02 AM
Ok, non-issue then. Looks like there's room for another object GC flag.
Err, maybe not. :P
 
5:26 AM
yeah but we've run out before, someone will come up with something if necessary ... we were running out when weakrefs was happening ...
(we can use type info of partial->This, we are doing that for other things)
 
 
2 hours later…
7:17 AM
Incident with GitHub Actions ・ GitHub Pages has Major Outage
 
 
3 hours later…
10:08 AM
Hi all
Why does PHP/Laravel save a transparent PNG file with a black background instead of a transparent one whenever it is uploaded?
$file = $request->file('file');
$image = Image::make($file);
$file->storeAs("images", "test.png", "uploads");
$image->save(public_path() . "/uploads/images/" . "test1.png");
On Windows, the file is saved transparent, but on Ubuntu, it is always saved with a black background.
 
10:24 AM
 
@CraigFrancis use Intervention\Image\Facades\Image;
I've used two methods:
$file->storeAs("images", "test.png", "uploads");
 
I'm not familiar with Intervention, but it does support GD and imagick drivers, which handle alpha transparency differently.
 
$image->save(public_path() . "/uploads/images/" . "test1.png");
I've changed the 'driver' in config\image.php to 'imagick'
 
cmb
GD requires imagesavealpha($im, true) to retain the alpha channel.
 
cmb
10:45 AM
@BenMorss, semi-good news: I've managed to get AVIF workin on Windows. The downside: avif.dll is twice as large as php_gd.dll (which has all other image libs built-in). And AOM doesnt build for me on x86.
 
Incident with GitHub Actions and GitHub Pages ・ GitHub Pages has Major Outage
 
@MRS1367 I'm not able to check 'imagick' at the moment (testing out something that does not have it installed)... but this seems to work fine for me:
use Intervention\Image\ImageManager;

$manager = new ImageManager(['driver' => 'gd']);

$image = $manager->make('./example.png');

$image->resize(200, 200);

// $image->save('./output/test1.png');

echo $image->response('png');
exit();
cmb is right about GD needing imagesavealpha(), and sometimes imagealphablending(), but it looks like Intervention is doing this for you already.
 
Thank you too for your replies @CraigFrancis and @cmb
 
@MRS1367 Oh, I think I know what it might be... $file = $request->file('file'); is from Laravel, and it provides a path is to the tmp uploaded file (tmp_name), which does not have a '.png' extension, so I don't think Intervention is treating it as a PNG?
 
11:01 AM
Yes the problem is exactly in there
It creates a temp file with jpg signature...
It basically converts the file to jpg.
 
great, so by hopefully changing that, it should start working.
 
So, how can I do that?!
The uploaded file always saves temporarily as JPG file...
 
cmb
@MRS1367 save() accepts a $format parameter (image.intervention.io/api/save)
 
Let me check @cmb and thank you
 
@MRS1367 What happens when you echo $request->file('file')->getRealPath(); ... is that where you're seeing the '.jpg' extension? during the reading process?
 
11:16 AM
@CraigFrancis /tmp/systemd-private-1eabb963108941a8b63e58f7458e1c0d-apache2.service-B0FPl9/tmp/phpIE73sZ
 
@beberlei Yes, they do work :) With a small modification, even non-readonly properties can be converted to typed properties. For now, the biggest question is if the types are really correct.
 
It's the temp file
@cmb When I do that nothing happens...
Because the original (temp) file is already saved as jpg.
 
oh, so you're uploading a jpg?
 
So the saved file also has a black background.
 
cmb
if the uploaded image is JPEG, there is no alpha channel; that would be an upload issue
 
11:19 AM
@CraigFrancis Nope
I upload/have uploaded the PNG file
59 mins ago, by MRS1367
user image
Just check this
My image is PNG
 
cmb
then I guess that the resize is the problem; you'd need to imagealphablending($im, false)
 
@cmb When a temporary file is saved as a JPG, how can it be saved as a PNG with a transparent background?
 
Sorry cmb, that was my example that did the resize... @MRS1367, you mentioned seeing a ".jpg" somewhere, where was that?
 
@CraigFrancis in temp folder
 
erm, but the temp path you showed didn't have a file extension?
 
11:24 AM
Something like this:
8 mins ago, by MRS1367
@CraigFrancis /tmp/systemd-private-1eabb963108941a8b63e58f7458e1c0d-apache2.service-B0FPl9/tmp/phpIE73sZ
 
Yep, but that file was called "phpIE73sZ", and shouldn't have been re-encoded as a JPG at that time (PHP typically creates that with the contents of the upload).
 
It hsn't the file extension
but when I open it in a text editor
It has JPG signature
Û’Ø·Û’à JFIF
 
ok, well something is happening between your browser uploading the file, and it being written to that file.
I don't think Laravel will do that, and this is before Intervention gets involved.
 
Front-end part of the project is written with Nuxt.js
And nuxt-dropzone is used to upload images.
 
can you clear out your tmp folder, and do a new upload... so you can see that a new file has been created.
 
11:28 AM
Yes
I did it before
and nothing changed
 
cmb
@MRS1367 quite likely this converts the PNG to JPEG before upload
 
I searched a lot on the internet but did not find an answer...
 
Seems strange for the JS to modify the file to a JPG.... and a quick look at dropzone looks like it's just for the drag/drop functionality (no mention of jpg in the source code)
 
@cmb Yes... Exactly and I know it... :(
 
sorry, gtg, good luck finding the next bit... but hopefully that has narrowed it down to the upload process.
 
cmb
11:32 AM
 
@CraigFrancis Thank you for your helps
@cmb nuxt-dropzone is based on vue-dropzone
And vue-dropzone is based on dropzone.js
@cmb And we've don't use it (mentioned property)
 
cmb
if you're dropping a PNG, but it is uploaded as JPEG, no PHP is involved there; must be a client side issue
 
Thank you
 
 
1 hour later…
@NikiC I've just found oci8.old_oci_close_semantics (php.net/manual/en/…). Can I add it to the deprecations RFC?
 
cmb
1:03 PM
maybe ask Chris Jones first?
 
yeah, I'll ping him
 
cmb
ta
 
1:37 PM
Chris Jones? Now that's a name I've not heard in a long... long time...
 
@JoeWatkins Sounds like nothing changed after I stopped talking last night, so... should I update the RFC?
 
cmb
 
The few, the proud, the quiet maintainers who just keep shit working.
 
@Crell yeah, think so ...
 
OK. I'll go do some open heart surgery this morning.
 
1:49 PM
I don't think levi is very happy about loosing named placeholders, but I think we should push on, in it's current form it's easier to understand than it has been ...
also note that dropping support for them barely changed any of our tests, it turns out they're not really that useful as placeholders, they're useful as arguments and that's mostly how we used them even in tests ... which is still okay, of course ...
 
@JoeWatkins I'm confused. When has he in favor of named placeholders?
 
he insists that he wants to make it work, that he doesn't want to ship an incomplete feature ...
 
That's not what he was insisting a few days ago.
He literally said that named targets on placeholders would be silently ignored and that that was a good thing.
Which isn't supporting them at all, it would prevent us from EVER supporting them.
FTR; I'm in favor of delaying PFA till 8.2 if that's what it takes to actually ship them as a complete feature which DOES work with named arguments (and any other syntax in the language).
But if we want it half done (with named targets explicitly blocked) in 8.1, that's also fine as it leaves the door open for improvement in 8.2
 
it's not really so simple, it's not a problem of figuring out syntax
 
Didn't say it was.
 
1:58 PM
honestly I can't see a way to do it reasonably, and I've spent too much time trying, it's a waste of my time at this point ...
 
Perhaps I'm naïve, but why not just do an AST transform to make it a literal closure? `foo(?, 42, ?)` => `fn($placeholder1, $placeholder2) => foo($placeholder1, 42, $placeholder2);`
I know it would get hairy with captures and the variadic question doesn't dissappear, but if those are solvable (and I think they are), then the named arg issue falls out as a neat solution
 
Incident with GitHub Actions, API Requests, and GitHub Pages ・ API Requests has Partial Outage ・ GitHub Pages has Major Outage
 
@Sara references
 
((in practice, you wouldn't actually do a transform as you'd loose the original source that way, but from an equivalence perspective it's easier to describe the approach))
@bwoebi Can you elaborate? That response isn't as self-explanatory as you seem to think it is.
foo(?, $x) (foo() taking second arg by ref) that sort of thing?
 
@Sara whether a variable shall be captured by ref or by-var is only known when the funtion has been resolved
so, not at compile time - we don't know which opcodes to emit thus at compile
 
2:03 PM
That seems solvable by using capture by reference in the transformed closure, then letting the function call inside the closure keep or clear the ref as needed.
So: foo(?, $x) => function(&$placeholder) use (&$x) { return foo($placeholder, $x); }
 
I am coming around to the idea that we don't want to have named placeholders even if it could be made to work. The more I think about it, the more it's just unnecessary.
 
@Sara but then $a = foo(?, $x); $x = 1; $a(2); has a different behavior than if it were $a = fn($arg) => foo($arg, $x) (if foo does not take by ref)
 
it is a bit naive ... doing fn() => is easy in userland, we can't really use ast, what you're really talking about is turning every application site into a declaration site, and that comes with a huge amount of complexity ...
 
@Crell When I asked you about arg reordering, you said "use named args" and that convinced me the use case was solved for. If we no longer have named args, then we no longer have a solution for that use case. So what is your answer to argument reordering now?
@JoeWatkins "We can't really use AST" <--- Citation needed.
@bwoebi Excellent point.
@bwoebi Okay, I have zero solution for that atm...
@JoeWatkins "...what you're really talking about is turning every application site into a declaration site..." I'm really not though.
 
Given four($a, $b, $c, $d), if you want to get a function you can call as partial_four($d, $b)... Then call partial_four(d: 4, b: 3); There's no need to create a function that is actually partial_four($d, $b), because you can call it with named arguments if you really need to.
And I think the use cases for that are pretty minimal to begin with.
 
2:09 PM
@Crell That's a solution to a completely different problem.
 
And named arguments at the partial site are still supported. This will always work: four(?, d: 4, b: 2, a: 9); Or four(?, ...$args);
 
Here's what reddit will ask for (mark my words):
$myInArray = in_array(haystack: ?, needle: ?);
 
@Sara the function isn't known at compile time, how do we determine how to transform the ast without the declaration of the function available ?
 
@Crell Show me your actual definition for $partial_four in this conversation?
@JoeWatkins From the declaration of the partial
 
@Sara you really are
 
2:12 PM
If you really really really need to do that, $myInArray = fn(array $haystack, mixed $needle): bool => $in_array(haystack: $haystack, needle: $needle);

That already works and is still acceptable if you want to do something silly.
 
@JoeWatkins With all due respect sir, fuck you. I know what I'm talking about, you're making baseless assumptions.
@Crell It does work, and I agree. I'm telling you what argument you're going to hear.
 
@Sara the solution would be: finally require callers to specify by-ref passing via a leading & sigil (and callees as well)
 
$partial_four = four(1, ?, 5, ?); // Gives a function with signature f($b, $d)
 
@Crell Show me your actual definition for $partial_four in this conversation?
 
@Sara that makes no sense, partial application is not a declaration, it's a partial call, not a partial declaration ... when the code is generated for that application, if the function being called is not known, we cannot possibly know how to transform it ...
 
2:14 PM
@Sara I am prepared to tell Reddit it's wrong.
 
@Crell Okay, so now you're calling $partial_four(d: 123, b: 456); WTF do 'd' and 'b' refer to here? Because they don't refer to any arguments in $partial_four itself. They're passed down to four() in a way that leaks implementation details to the top caller. That is MANIFESTLY worse.
@JoeWatkins I'm done talking to someone not interested in a good faith argument.
 
what ?
 
I... genuinely don't know what you just said.
 
@Crell I'm saying all the top caller knows is that they're calling $partial_four. They know nothing else.
 
A partially applied function's arguments inherit all aspects from the function being partially applied. Name, type, default value, etc.
 
2:17 PM
@Crell However $partial_four doesn't have any names to any of its arguments.
@Crell And that's the bad design.
 
Wha?
 
Ya
 
There's some seriously significant comprehension mismatch going on here, because what you are saying does not make any sense to me in the slightest.
 
Ditto.
I'm not even sure we're talking about the same feature at this point.
 
Distinctly possible.
1. Parameter names in the $partial function *are always the same as those from the original function*. Ever and always, amen.
2. The order of parameters in the $partial function *is always the same as those from the original function*, ever and always, amen.
3. Parameter types in the $partial function *are always the same as those from the original function*, ever and always, amen.
We're all on the same page on those 3 points, yes?
 
2:20 PM
As far as I can tell, you want a bit of magic that neither declares a proxy nor actually takes any steps in calling a function. This means that arguments belong neither to the partial nor to the fbc. Until you can define them in a way that's consistent from both ends of the call, you're just describing wishful thinking.
@Crell Point 2 you promised me was something else and you've renegged. Yes.
 
I don't recall ever promising you parameter reordering...?
 
@Crell Sadly, SOchat's search functionality kinda sucks
But okay. We have those three points describing your RFC.
 
A miscommunication perhaps?
 
It's kinda weak sauce, but okay.
#3 seems obvious and there's no need to argue it. #1 is suspect, but harmless, no need to argue. #2 castrates the usefulness of this feature.
Doesn't make it useless, just less useful.
 
4. A partial application is triggered by the presence of at least one ?.
5. Any parameter you want to pre-fill may be done so either positionally or named, including variadic named. Use more ? to mark positional arguments you want to remain "open" in the partial.
 
2:27 PM
#4 No argument
#5 ? is positional only <--- That's my gripe.
 
See, I don't see #2 as a problem. I could see it as a might-be-nice, but in practice I suspect the majority of use cases will leave only one placeholder remaining anyway so it's a moot point.
 
That's in consistent syntax and it's the same mistake PHP keeps making.
My gripe with #2 is just a different version of my gripe with #5
The barrier for introducing inconsistent syntax MUST be high.
 
`four(d: ?, c: ?, a: 4, b: 3);`

Does that imply
partial($d, $c)
or
partial($c, $d)
 
And you're not going to get me to budge on that high-level position.
@Crell Neither, because your example is incomplete.
@Crell Being imprecise in your examples is how we're getting into miscommunication territory,.
 
how so?
 
2:30 PM
What is partial, you haven't defined it.
What is $c and $d, you haven't defined them
You've left a great deal as implied in a conversation that has already proven itself to have an impedence mistatch.
 
function four($a, $b, $c, $d) { print "$a, $b, $c, $d\n"; }
$partial = four(d: ?, c: ?, b: 2, a: 1);

$partial(3, 4):

// Which of these gets printed?
1, 2, 3, 4
3, 4, 1, 2
3, 4, 2, 1
1, 2, 4, 3
 
1, 2, 4, 3
Or should be, if you want consistent syntax.
 
That's inconsistent with how named args work otherwise, where the names map but the order is defined by the function, not the call site.
And I will take Joe's word for it that it's harder to do. (That discussion is over my head.)
 
The trouble is, we have TWO callsites.
We have the definition of the PFA which is a callsite, it's where we (P)artially (A)pply the (F)unction. And we have the final callsite, where the PFA is invoked.
Forget implementation for a moment here. What are users going to see in this feature, and how will they use it.
 
My expectation (on which I have no specific data, but then neither does anyone else) is that most use cases are going to have only a single placeholder anyway, producing a unary closure, so the issue is moot to begin with.
 
2:37 PM
Agreed on that point.
But we're not limiting PFA to single arg.
And if we're going to allow multiple args, then we need to define the edge cases.
 
"Named arguments can appear in any order, and the order in the function getting called is what matters" is the logic today, yes?
 
So your point is also a non-sequiter.
@Crell I'm having trouble parsing the second half of that sentence.
 
four(d: 4, c: 3, b: 2, a: 1); - The order there doesn't matter. four() sees an argument list of [1, 2, 3, 4]; Right?
 
Applying that back to your previous definition of the function four(), yes. I'll take the stipulation that this is no different than calling it as four([1, 2, 3, 4]...);
 
Yes, using the same four(). And calling it with that array variadic is also equivalent.
 
2:41 PM
WITH the caveat that the person defining four() in the first place can change their declaration to move arguments and the call is now different
 
Yes, but if the author of four() moves parameters around it's an API change anyway and all bets are off. That's been the case since PHP 3.
 
And that's pretty important to the feature of named arguments
But the function would continue to work for someone explicitly passing arg names.
 
Granted.
 
So not ALL bets are off, but I'll admit I'm splitting hairs here.
Going to repeat though, details matter, and you can't just throw a new feature at the wall and hope the edge cases sort themselves out. That's how we got PHP 4.
 
So now:
$partial = four(d: 4, c: ?, b: ?, a: 1);
$partial(c: 3, b: 2);

This would also send [1, 2, 3, 4] to four(), yes?
 
2:44 PM
Sure. Assuming your syntax allows it, which I (think) it does?
 
(Hypothetically speaking, it the first line were made legal.)
As of right now, no.
 
Just to clarify, what does the current patch do with that?
 
Syntax error, I believe. Because c: ? is not allowed.
 
On the line: $partial = four(d: 4, c: ?, b: ?, a: 1); specifically?
 
Correct.
 
2:46 PM
So if we change your code to:
$partial = four(d:4, ?, ?, a: 1);
$partial(c: 3, b: 2);

What would happen?
 
Syntax error, named args before positional args, I think.
 
That wasn't supposed to be an edit, sorry...
 
:-)
 
So if we change your code to:
$partial = four(?, ?, d:4, a: 1);
$partial(c: 3, b: 2);

What would happen?
 
[1, 2, 3, 4]
 
2:50 PM
Well, it's better than last week where the $partial = four(d: 4, c: ?, b: ?, a: 1); example wouldn't even error, but I'm not convinced it's the right tack.
Let me think about it for a bit.
I do like that there is SOME story for named arguments now.
 
So now, given this:

$partial = four(d: 4, c: ?, b: ?, a: 1);
$partial(2, 3);

What happens?

Argument for 1, 2, 3, 4: Named args don't affect order, therefore four() gets 1, 2, 3, 4.
Argument for 1, 3, 2, 4: The "layer below me" implies the order is c, b, therefore that's the order I think I should be using.

I... could probably make a decent case for either one if I were on the debate team. Both have a valid argument for them, but we obviously can't do both.
 
I think this is the key point that needs to be in big friendly letters somehow in the documentation (and in the RFC, but orders of magnitude more will see it in the documentation):
11 hours ago, by Joe Watkins
they're partial calls, not partial functions, they're not declarations, that's the problem ...
 
"""Argument for 1, 2, 3, 4: Named args don't affect order, therefore four() gets 1, 2, 3, 4.""" You seem to be arguing for named args TO effect order there.
 
Bug in my example, I think.
Fixed just before the editing deadline.
 
:D
I'm.... not seeing the edit?
 
2:54 PM
Changed the call to $partial(2, 3)
 
Right, got it.
 
Per Joe, the second possibility is really hard. So we can either go with option 1, and lead to people getting confused that it may mean the second, or we can make that syntax illegal as it's too confusing, AND hard to do.

Making it illegal leaves open the possibility in the future to figure out how to implement the second interpretation if we want, and can get a consensus that it's the right interpretation.
 
So in that example, my FIRM argument against "Named args don't affect order," is that you've allowed them to be represented at all.
 
I think the source of a lot of the talking past each other is this: if you think of "foo(?, 42)" as syntax sugar for a call like "fn($x) => foo($x, 42)", then there needs to be something that "builds" the argument list in the fn() part; but what's actually happening (I think - somebody please correct me if I'm still wrong) is that you start with the original function signature, and then the partial definition splices in some fixed parameters
 
Which is why the present state is at least better.
@Crell "It's hard" is a reasonable argument for "let's not do it", and even if we could do it, then we'd need a story for when different, conflicting arg names are provided
 
2:57 PM
The plan at present is to make $partial = four(d: 4, c: ?, b: ?, a: 1); just not allowed at all. Instead you'd write four(?, d: 4, a: 1), which gives you the original four() but with the values for $a and $d "spliced in" (to use @IMSoP's terminology).
 
@Crell Okay, you've just brought up my second gripe, and that's this idea that a single '?' can be a placeholder for multiple args.
I get the argument for it. YES I REALLY FUCKING DO, DON'T TELL ME I DON'T.
 
One gripe at a time, please. :-)
 
On the first gripe, I'm not sure there's anything left. We have a state that isn't terrible. I don't love it, but it's viable.
 

« first day (3865 days earlier)      last day (1065 days later) »