-
Notifications
You must be signed in to change notification settings - Fork 14
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
Idea: short circuit AND #120
Comments
Hi ape, good to see you out here! I the issue to gta3script-specs, since this seems like a language design issue rather than an implementation one, I assume it's ok on your side (EDIT: Ok, GitHub does not allow transfers between organizations, great). Indeed. The lack of short-circuits made the scripters perform these deeply nested IF chains. It's interesting to note GTA2script had a more complex if construct, which among other things, permitted short-circuit evaluation. I think the correct way to handle this is by Similarly, an I think All that said, I'm against the addition of this feature. It seems to be a fundamental design choice, and they coded five games without bothering. It's rather easy to transform a very simple language into a complex language by adding syntactic changes every here and there. Given scripters annoyed by this pattern, I would rethink my position. Hope you understand. |
Sure, i understand not wanting to change the language spec. I have implemented a short circuit and in my decompiler now and this:
turns into
It also improves else-analysis because now a deeply nested IF with a GOTO to after an ELSE part of an outer IF can now be analyzed as a proper ELSE, even if they used a manual GOTO in the source. |
I have been working on a decompiler recently and noticed quite a lot of nested IFs that are essentially a short circuit AND. I think these were written as a chain of manual 'GOTO else' by the scripters. The language would benefit from a proper short circuit AND. If we can decide on a syntax and you implement it, the decompiler output could be a bit nicer.
Two ideas for a syntax: either use a modified IF (say IFX) and only allows AND or use a modified AND (say ANDX) with the regular old IF. I don't know which one is better, but I think I'd prefer the second.
EDIT: an example:
The text was updated successfully, but these errors were encountered: