Repository navigation
[RESOLVED] Warning if variable is re-assigned? #1159
Replies: 3 comments 1 reply
|
I'm less persuaded this is almost always an error. e.g. say we want to replace nulls with zero: Almost all programming languages allow reassignments andor mutations... |
Yes, but the mistake I'm trying to guard against is mistyping a complicated column name (I have plenty of similar ones in my application: SDAppTotal2021 and SDAssTotal2021) and having it disappear from the resulting table because it got reassigned... That said, your example is a compelling use case. Furthermore, it "does the right thing" if extended like this: generates: It seems there's tension generated by the dual purpose of
I was initially thinking about the way Javascript makes a distinction between I wonder if it's sufficient to require re-assignment to occur on one line: e.g., |
|
Thanks for that link to the previous discussion. I'll just have to be careful when typing variable names. (And why wouldn't I want to do this? :-) |
Uh oh!
There was an error while loading. Please reload this page.
Currently, PRQL sets a variable to its latest assignment, losing/ignoring any earlier value. For example:
yields
It seems to me that this is almost always an error - either a simple typo or a deeper problem - and should be flagged as an error.
Is there ever a case where re-assignment could be useful? Thanks.
All reactions