> > spawning in a scope a "second-class citizen" if `spawn foo($bar);` >
Reminds me of *"post-purchase rationalization"* or the *"IKEA effect".* when effort has already been invested into something, and then suddenly, there's a more convenient way. And that convenient way seems to devalue the first one. But it looks like the `$scope->spawn` syntax really does have an advantage over `spawn in $scope`. So what do we do? Avoid using what's convenient in pursuit of perfection? > I did say the names were subject to bikeshedding Yes, I don't disagree that a keyword would be very useful, even outside the context of coroutines. And again, there's the question of whether it should be introduced directly in this RFC or if it would be better to create a separate one. > > I'm confused - $scope->onExit() is already in the RFC, and I wasn't suggesting any change other than the syntax. > (Although I'm not sure if it should defer to coroutine exit rather than scope exit by default?) > Yes, that's correct. The onExit method can be used for both a coroutine and a Scope. As for the method name onExit, it seems like it would be better to replace it with something clearer. > > spawn foo(42); > // spawns a call to foo with argument 42 > I like it. > > spawn call bar(...); > It doesn't make sense because the arguments must be defined. By the way, I looked at the definitions in the Bison file this morning, and in principle, there's no problem with doing this: ```php spawn use(): returnType {}; ``` > Is this just a description of your own comprehension, or based on some more general experience of something similar? Yes, it's more of a mental model. > > Is there a reason to redefine all of this and make fresh decisions about what to allow? > If we strictly follow syntax consistency, then of course, we need to cover all possible use cases. But when I see code like this: ```php spawn ($this->getSome()->getFunction())($parameter1, ...); ``` I start seeing circles before my eyes. 😅 Okay, if we're going that route, then at least something like this: ```php spawn $this->getSome()->getFunction() with ($parameter1, ...); ``` So the syntax would be: ``` spawn <exp> [with (<args>)]; ``` So... ```php spawn test with ("string"); spawn test(...) with ("string"); spawn test(...); // without args spawn function(string $string) use() { } with ("string"); ``` These examples look better in terms of consistency, but they are no less surprising. --- Ed.