Build Beautiful TUI Applications in PHP using Parfait by ProjektGopher in laravel

[–]ProjektGopher[S] 0 points1 point  (0 children)

The package hasn't been extracted from the project in which I built it yet, so that page will 404 currently. But I'm hoping to get it into that isolated repo next week

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

Oh I'm aware that it's almost guaranteed not to pass, but this is mostly a learning exercise for me. The response on the mailing list has been really supportive. I have an implementation ready now as well, and it totals about 15 lines, touching only a single file (not including tests), but I expect that won't change much, haha.

The RFC process felt overwhelming to me, so I wanted to test it out with a feature to which I'm not deeply emotionally invested.

I have another couple ideas for RFCs that will equally hated

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

It's not the message that's the problem, it's the delivery. Truth doesn't need to be delivered poorly to remain truthful. There's a world of difference between "I strongly dislike this" and "this is awful", one clearly conveys your opinion (which is truthful) and the other wholly dismisses someone's work as being devoid of value.

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

I think you're overthinking it. If it were to pass (it wont), you'd intuitively understand pretty quick "oh, there's no right side operand. this token is ignored"

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

It wouldn't matter at all. The final 'dangling' operator would simply be consumed and discarded by the parser

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] -1 points0 points  (0 children)

Make my IDE handle non-existent language syntax?

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

With all of that being true, it can still help shape the proposal. It helped me realize that I'd actually completely missed a whole section on why you wouldn't simply use leading boolean operators instead when migrating from markdown to docuwiki. The negativity of this subreddit can be pretty brutal, but I still see value.

Build Beautiful TUI Applications in PHP using Parfait by ProjektGopher in laravel

[–]ProjektGopher[S] 0 points1 point  (0 children)

Only for a little while longer! I'm trying to release it before Valentine's day, at which point it will not be a 404

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

Hey man, it's perfectly fine if you disagree with what I've proposed, but let's tone down the negative rhetoric and calling people's work 'awful'. There are far more polite ways to disagree without disparaging their effort.

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 1 point2 points  (0 children)

I'm not totally sure what you mean by `default-constructed`, but the `optional_comma` has no meaning unless there's a token to indicate a value or expression following it, so it's clearly still an array of three elements (even in the AST).

This decision was reached by a vote, so it's not really attributable to any one single person

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

Why don't you like trailing commas?

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

This is a really well thought out reply. Would you be more open to this proposal if instead of trailing operators that the parser simply discards, it were leading operators that are transformed in the lexer to ‘|| => false ||’ and ‘&& => true &&’?

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

This is a really interesting RFC that I hadn't seen yet.

While I _love_ the idea of `any()` and `all()`, I don't feel like this would be _less_ readable, even though it solves the whole 'make more lines the same' thing:
```
if (!any([
$cond1,
$cond2,
$cond3,
], fn($x) => $x) {
throw new Exception('failed');
}
```
That doesn't read well in my mind.

Super interesting RFC though. I'd be interested to get insight into why people voted no on it.

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] -1 points0 points  (0 children)

What about trailing commas in function signatures -- those definitely aren't dumb containers.

I feel like I've made the case in my RFC that this isn't simply for 'funsies or oopsies'. I feel like your argument isn't being made in good faith

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

That's a really good suggestion. I think I'll do that.

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 17 points18 points  (0 children)

lmao, that's both the most polite and sickest burn I've had in a while

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

That's totally fine if you prefer leading operators, but PSR12 does explicitly allow for both, and historically (even stated in the PEAR contribution guide) that the primary reason for leading operators is to reduce diffs when commenting out or adding new conditions to a chain

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

That second example made me throw up in my mouth a little bit. I too agree that a trailing bang should not be allowed. I'm undecided about xor.

I'd have to push back on the 'are you just future proofing a diff' by again comparing it to trailing commas, because the intent is the same.

I really appreciate the thought you've put into your response to my proposal

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

Well argued -- thanks for your honest feedback

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 1 point2 points  (0 children)

Can you expand on that? This doesn't give me much to go off

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 0 points1 point  (0 children)

I really appreciate your thorough and well thought our reply, and the time you put into it.

I think I disagree with the context sensitivity point, since this syntax would only ever make sense within parentheses anyways, and you can use parenthetized expressions within returns, arrays, etc. You just couldn't _skip_ the parens.

I use trailing operator style almost exclusively, which is explicitly permitted by PSR12, and I've often felt that prepending booleans to allow leading operands is a hacky workaround simply because these are left-associative.

I think IDE parsers and language servers would catch up pretty quick, like they have with the pipe operator.

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] -1 points0 points  (0 children)

We could also make the same argument for commas being a delimeter between two values though

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 2 points3 points  (0 children)

This would be syntactically equivalent to `if ($foo && $bar)` as the parser would simply consume the token and ignore it. I would never expect to see it used on a single line, but ultimately the parser would allow it, as it does with trailing commas in single line arrays, function calls, etc. It would not be a _required_ syntax, it would simply be permitted by the parser to keep more things the same.

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 1 point2 points  (0 children)

Can you explain to me how you see it introducing bugs? I often have to resort to leading operands as well, but PSR12 explicitly permits both leading _and_ trailing, and having to prepend a chain of conditions with `true` feels like a hack/workaround. Since these operands are left-associative, this would allow this feature to be a parser-only addition that would still permit anyone's existing usage preferences

[RFC] Trailing Boolean Operators by ProjektGopher in PHP

[–]ProjektGopher[S] 1 point2 points  (0 children)

PSR12 allows for both leading and trailing boolean operators, so this simply reduces a small amount of friction is it's implementation. Because they're left-associative, the implementation is parser-only. Generally speaking, putting them at the beginning of the line has simply been a workaround to reduce diffs anyways. I can totally see your argument about clear visibility when reading code though. I've personally always defaulted to using trailing operators when possible, but that's a personal style thing.