-
Notifications
You must be signed in to change notification settings - Fork 15
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
toLeopard: Inconsistency when renaming variables with illegal characters #120
Comments
I think we're just stripping illegal characters and then tacking on a I wouldn't be opposed to ensuring the first variable of a duplicate name gets a Just going to /cc @PullJosh since this is a minor change in project translation, do you agree/disagree or have any additional nuance to add? |
I definitely like your suggestion of appending a 1 to the first of the would-be-duplicate identifiers. That seems like a strict improvement over what we have now. Brainstorming other ideas: just recently I translated a project that had a variable called So here's an idea:
Thoughts? |
I like it! Also pinging @adroitwhiz, not sure you're around but would be nice to get your feedback. We can build on this more later if there are other ideas present, but the outline above feels pretty good. That said, it's worth noting that I don't think there's a lot of advantage to using bracket notation when dot notation is (albeit surprisingly) functional. I'd swap step 2 for a more specific "Strip characters that aren't valid in JavaScript identifiers", which would implicitly include apostrophes, exclamation marks, etc. There should be very few variable names that are entirely composed of invalid characters - stuff like |
Wow! I had no idea all of that was valid! Yeah, I love your proposal of stripping invalid characters but leaving everything else in place. |
Another thing you could do is just alphabetically sort the variables before replacing invalid characters. That way, variable names are consistent. |
D'you mean consistent between multiple times converting the same project? (Does the edit: Or just to match the alphabetical order in Scratch? If so then yeah, that makes sense to me as something we could easily do, too (at least before addressing this more effectively!). |
I meant that the issue wouldn't be as bad if variables were sorted before replacing invalid characters and deduping. That way, if you had two variables differentiated by an invalid character, they will consistently have the same suffix. |
While trying to convert the attatched project, among other things, the
_.density
and-.density
variables were renamed to,density
anddensity2
.However, when I was looking through the code in
Engine.js
, theRtImpulseGetDataOfObjectWithId
function used variables that ended with a '2' along with variables that did not end in a number. This is not really an issue, but it makes trying to use the output of Leopard difficult.The project: distilled-impulse.sb3.zip
The text was updated successfully, but these errors were encountered: