You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C-style languages use = for assignment and == for equality. This has the nice side-effect that statements are also expressions: an assignment statement x = 4 is also an expression which returns the value 4 (i.e. the result of the assignment). However, it means having to use a different symbol/syntax for equality.
VBScript (which has had more of an influence on Rockstar than I'd like to admit) uses = for both assignment and equality, and the operator behaves differently whether it's in an expression or a statement context. VB has two functions for running code at runtime: Execute() will execute a statement (but not return anything), and Eval will evaluate an expression (but can't be used to execute statements).
I'd very much like to adopt the C-style philosophy that statements can also be expressions, but this means the keyword is (and aliases was, were, etc) can't be used for both assignment and comparison.
One option would be to restrict is to equality, and use different syntaxes for assignment:
X is 5 (expression which returns true/false depending on the value of X)
Let X be 5
Make X 6
Put 7 into X
Anybody got any other good ideas as to how we might resolve this?
The text was updated successfully, but these errors were encountered:
Only one idea came into my mind: assignments could use has, have, has got, have got's gotgot (possessive expressions) syntax for an assignment expression. It's an unused yet very common language feature, I think.
Janie’s got a gun (assigns Janie the value of 'a gun', single statement)
It would save this famous line, since the poetic assignment now requires the like keyword. It's a breaking change anyways.
Let a mistake be like a kiss
While our love has a mistake without like forgiveness is stronger than nothing
Make a mistake our love
Shout our love! Baby
(counts down from 3 to 1)
(Don't ask how much time did it take to create a bearably-sounding example... 😅 )
The key is the While line: we assign a mistake - 1 to our love, then compare the value to 0.
The bad thing is that we may lose the in-place increment/decrement capability (our love has without 1 would be really useful but does not sound good at all, at least for me)
Background:
C-style languages use
=
for assignment and==
for equality. This has the nice side-effect that statements are also expressions: an assignment statementx = 4
is also an expression which returns the value4
(i.e. the result of the assignment). However, it means having to use a different symbol/syntax for equality.VBScript (which has had more of an influence on Rockstar than I'd like to admit) uses
=
for both assignment and equality, and the operator behaves differently whether it's in an expression or a statement context. VB has two functions for running code at runtime:Execute()
will execute a statement (but not return anything), andEval
will evaluate an expression (but can't be used to execute statements).https://ericlippert.com/2003/09/20/why-does-vbscript-have-execute-executeglobal-and-eval/
I'd very much like to adopt the C-style philosophy that statements can also be expressions, but this means the keyword
is
(and aliaseswas
,were
, etc) can't be used for both assignment and comparison.One option would be to restrict
is
to equality, and use different syntaxes for assignment:Anybody got any other good ideas as to how we might resolve this?
The text was updated successfully, but these errors were encountered: