It's been brought to my attention that many people are unhappy with how SourceCoder optimizes programs. The optimization features are actually not of my own design, but integrated from a project a half-decade ago called OptiBASIC by UnitedTI member Brazucs. I knew that the features worked relatively poorly, but always figured they were more of a guide to coders than something to pass your code through for optimization. I assumed people would prefer to just learn good coding habits and do hand-optimization. Here's what SourceCoder currently (tries) to do:
Check out this post if you want to see the Regex that makes this all possible
:: Remove a closing ) or }, but only if it's followed by a :, a newline, the end of the program, or some character I don't recognize with Unicode ID 8594.
:: Remove a single-quote followed by a newline, provided that it's not delimiting a blank line
:: Replace a number by itself in a string with just the number, to save the quote byte.
:: Remove the Then and End around a single statement after an If, including constructions like If \ Then \ Goto \ End.
:: Remove the construction Output(1,1,". I'm unsure what this is for.
:: Convert Disp "string" \ Pause to Pause "string"
:: Turn Stops into Returns. Because, come on.
:: Remove any Return that's the last command in a program
:: Replace 0->var with Delvar var
:: Remove the newline or colon after a Delvar.
:: I'd have to look closer at this to understand fully the logic it applies, but the high-level interpretation is that it changes If BLAH!=0 to If BLAH. and If BLAH=0 to If not(BLAH.
:: Remove the final ,1 increment in For( loops with it.
:: Replace ^2 with the exponent 2.
:: Same with ^3 -> exponent 3.
:: Implicit multiplication creation.
:: No point having 1 as a coefficient.
:: Replace series of Disp A \ Disp B or Prompt A \ Prompt B with Disp A,B or Prompt A,B
:: combine boolean expressions
:: more of same.
:: This massively complex thing does some kind of If \ Store statement compression to value(conditional)->variable expression
:: Remove blank lines
:: I have no idea. I'd have to work this one out more carefully.
:: No point storing to Ans.
:: remove extraneous parenthesis around division
:: same thing, but for the first half of the division
:: Remove extraneous addition and subtraction parentheses, but I think this one might be functionally incorrect (same with the division)
:: Combine Disp / Input or Disp / Prompt into a single Input or Prompt.
MY QUESTIONS TO YOU
(1) Would it be worth my time for the optimizer to work better?
(2) If yes to (1), tell me what you want the optimizer to do.
Check out this post if you want to see the Regex that makes this all possible
:: Remove a closing ) or }, but only if it's followed by a :, a newline, the end of the program, or some character I don't recognize with Unicode ID 8594.
:: Remove a single-quote followed by a newline, provided that it's not delimiting a blank line
:: Replace a number by itself in a string with just the number, to save the quote byte.
:: Remove the Then and End around a single statement after an If, including constructions like If \ Then \ Goto \ End.
:: Remove the construction Output(1,1,". I'm unsure what this is for.
:: Convert Disp "string" \ Pause to Pause "string"
:: Turn Stops into Returns. Because, come on.
:: Remove any Return that's the last command in a program
:: Replace 0->var with Delvar var
:: Remove the newline or colon after a Delvar.
:: I'd have to look closer at this to understand fully the logic it applies, but the high-level interpretation is that it changes If BLAH!=0 to If BLAH. and If BLAH=0 to If not(BLAH.
:: Remove the final ,1 increment in For( loops with it.
:: Replace ^2 with the exponent 2.
:: Same with ^3 -> exponent 3.
:: Implicit multiplication creation.
:: No point having 1 as a coefficient.
:: Replace series of Disp A \ Disp B or Prompt A \ Prompt B with Disp A,B or Prompt A,B
:: combine boolean expressions
:: more of same.
:: This massively complex thing does some kind of If \ Store statement compression to value(conditional)->variable expression
:: Remove blank lines
:: I have no idea. I'd have to work this one out more carefully.
:: No point storing to Ans.
:: remove extraneous parenthesis around division
:: same thing, but for the first half of the division
:: Remove extraneous addition and subtraction parentheses, but I think this one might be functionally incorrect (same with the division)
:: Combine Disp / Input or Disp / Prompt into a single Input or Prompt.
MY QUESTIONS TO YOU
(1) Would it be worth my time for the optimizer to work better?
(2) If yes to (1), tell me what you want the optimizer to do.