-
Notifications
You must be signed in to change notification settings - Fork 24
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
Reword REPLACE #212
Comments
I'm not suggesting any alternatives. I am proposing that we change the current syntax for |
Ah! Right! Yes, I like the alternative you propose. |
I agree, the current syntax reads really awkward. My friend ChatGPT also agrees: Me: "I'm creating a programming language. One of the statement allows you to replace text. I have two possibles syntaxes for it (the parameters are between < and >): REPLACE < searchFor > FROM < inString > WITH < replaceWith > IN < variable to hold the result > REPLACE < searchFor > WITH < replaceWith > FROM < inString > IN < variable to hold the result > Which one is better?" ChatGPT: "The second syntax is better because it follows a more logical order and is easier to read. It first specifies the text to be replaced, then the replacement text, then the string where the replacement will take place, and finally the variable where the result will be stored. This follows the order in which a person would naturally think about the task of replacing text. The first syntax does not have a clear order and could be confusing for a programmer to read and understand." Me: "I also want a variant that replaces the text in place, what do you think and what syntax do you propose?" ChatGPT: "For a variant that replaces the text in place, I would recommend the following syntax: REPLACE < searchFor > WITH < replaceWith > IN < inString > This syntax clearly specifies the text to be replaced, the replacement text, and the string where the replacement will take place. It is concise and easy to read, and it follows the logical order of the task. It also avoids the need for an additional variable to hold the result, which makes it more efficient and straightforward to use." |
Holy fuck the machines are rising run to the hills! |
While looking at #205, I noticed
compileman.php
does lots of string replacing.In PHP and other languages, you use something like
replace(inString, searchFor, replaceWith)
But in LDPL, it's more like
replace(searchFor, inString, replaceWith)
. Which is fine, but seeing a bunch of them in a row makes it a bit less clear what's actually going on:As opposed to something like this, where the connections are closer and slightly more obvious
So anyway, I'm proposing adding a new syntax for
REPLACE
and using that in all the docs, but still keeping the old one around as a forever deprecated alternative.As a bonus, would this be worth adding too?
The text was updated successfully, but these errors were encountered: