ENIGMA Forums

Contributing to ENIGMA => Proposals => Topic started by: Goombert on December 30, 2014, 12:55:38 am

Title: Disabling Automatic Semicolons
Post by: Goombert on December 30, 2014, 12:55:38 am
After I fixed the primitive arrays with Josh's help I wanted to fix initializer lists, they are only broken because of the automatic semicolons, when this is disabled they work. Harri's matrix array initialization is primarily what inspired me.
http://enigma-dev.org/forums/index.php?topic=2397.msg24374#new

This was my attempt here:
https://github.com/enigma-dev/enigma-dev/pull/917

But it ultimately fails because we simply don't have sufficient information to do this yet and a number of games are failing to parse after the changes. A better work around for the time being would be to add an option to disable automatic semicolons all together, this means you would have to always put your ';' terminating semicolons where they belong. But it would stop some things like initializer lists from breaking.

This would make the following possible in ENIGMA if you choose to disable it.
Code: (EDL) [Select]
int arr[2][3][4] = { { {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4} },
                     { {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4} } };

for (int r = 0; r < 2; r++) {
    for (int c = 0; c < 3; c++) {
        for (int n = 0; n < 4; n++) {
            show_message(string(arr[r][c][n]));
        }
    }
}

I would appreciate feedback on this and whether you guys think a setting for this would be nice. It should be considered an advanced setting as advanced users are more likely to properly terminate statements.
Title: Re: Disabling Automatic Semicolons
Post by: Josh @ Dreamland on December 30, 2014, 12:57:23 am
A setting to disable that is a bad idea unless we can accurately report errors on it. Your reason to disable it is that you can't accurately determine whether a semicolon is required.
Title: Re: Disabling Automatic Semicolons
Post by: Goombert on December 30, 2014, 12:58:57 am
I am like 99% certain without testing that the MinGW errors should show in LGM's console, I am like, almost certain. Though our syntax checking itself would not catch the error. To reiterate those may not be very user friendly but again this setting would be for advanced users, like Harri, who know C++.
Title: Re: Disabling Automatic Semicolons
Post by: TheExDeus on December 30, 2014, 08:30:56 am
Yes, I do put semicolons everywhere myself. And mingw would return the error, but the parser will not (so the syntax check button will not do it). This will hurt novice users that come from GM, but an option for stricter syntax would be useful anyway, so people would learn how other languages do it, not only GM which allows you to code in 6 different styles.
Title: Re: Disabling Automatic Semicolons
Post by: Goombert on December 30, 2014, 10:29:58 am
I have tested and the setting seems to be a suitable fix pro tempore. I have sent a new pull request. This is also a nice setting even if the user just wants to compile projects faster because they can skip this phase entirely. Therefore I agree with Harri that this is a smart way of teaching users that by coding properly they can write faster and more efficient software.
https://github.com/enigma-dev/enigma-dev/pull/919
Title: Re: Disabling Automatic Semicolons
Post by: Josh @ Dreamland on January 01, 2015, 12:06:53 pm
The question isn't "should we have a setting to teach users to add semicolons themselves," the question is "should we have a setting that offloads the responsibility of producing accurate C++ code to users because ENIGMA apparently can't." The answer to the former is yes; I've had dozens of requests to warn on missing semicolons and badly-formed code. The answer to the latter is certainly no; that's a pretty pitiful thing to do. But I won't stop you—the current parser is primarily duct tape as it is; what will an extra roll or two hurt?