Pages: [1]
  Print  
Author Topic: Disabling Automatic Semicolons  (Read 1580 times)
Offline (Male) Goombert
Posted on: December 30, 2014, 12:55:38 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2992

View Profile
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.
« Last Edit: December 30, 2014, 09:49:12 AM by Robert B Colton » Logged
Welcome to ENIGMO, the game engine built by fucking aliens.

Offline (Male) Josh @ Dreamland
Reply #1 Posted on: December 30, 2014, 12:57:23 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2934

View Profile Email
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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Goombert
Reply #2 Posted on: December 30, 2014, 12:58:57 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2992

View Profile
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++.
« Last Edit: December 30, 2014, 01:02:21 AM by Robert B Colton » Logged
Welcome to ENIGMO, the game engine built by fucking aliens.

Offline (Unknown gender) TheExDeus
Reply #3 Posted on: December 30, 2014, 08:30:56 AM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
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.
Logged
Offline (Male) Goombert
Reply #4 Posted on: December 30, 2014, 10:29:58 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2992

View Profile
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
Logged
Welcome to ENIGMO, the game engine built by fucking aliens.

Offline (Male) Josh @ Dreamland
Reply #5 Posted on: January 01, 2015, 12:06:53 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2934

View Profile Email
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?
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: [1]
  Print