-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment vs equality (and more generally, expressions vs statements) #333
Comments
Only one idea came into my mind: assignments could use
It would save this famous line, since the poetic assignment now requires the
(Don't ask how much time did it take to create a bearably-sounding example... 😅 ) The key is the |
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: