Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

This extension must be completely revised. #4

Open
stefsava opened this issue Dec 24, 2018 · 5 comments
Open

This extension must be completely revised. #4

stefsava opened this issue Dec 24, 2018 · 5 comments

Comments

@stefsava
Copy link

stefsava commented Dec 24, 2018

The example in README.md denote a poor knowledge of ruby language.

# Old syntax
data = [
  { 1 => "en", 2 => "to", 3 => "tre" },
  { :one => "un", :two => "deux", :three => "trois" },
  { "weights" => ["pound", "kilogram"], "lengths" => ["meter", "mile"] },
  { :de => { :one => "eins", :two => "zwei", :three => "drei" } }
]

# New syntax
data = [
  { 1: "en", 2: "to", 3: "tre" }, # syntax error: symbols can not start with numerical digits 
  { one: "un", two: "deux", three: "trois" },
  { "weights": ["pound", "kilogram"], "lengths": ["meter", "mile"] }, # bad replacement: keys was strings, but replaced with symbols
  { de: { one: "eins", two: "zwei", three: "drei" } }
]
@Kosai106
Copy link
Owner

You're right on the part about symbols not being able to start with a number, that was an oversight on my part. However I'd say it's a bit extreme to demand that everything should be revised based off of that.

As for your second point, if doing this would cause issues with your code, (Doesn't in mine) then just don't run the command on the affected lines. Simple.

@patbl
Copy link

patbl commented Jan 6, 2020

It's surprising that this extension subtly alters the behavior of hashes that have string keys. This could cause people who think that the altered code is semantically equivalent to introduce bugs into their code. I think a more conservative approach—applying the transformation only to keys that are symbols—would lead to less wailing and gnashing of teeth.

That's how this Emacs package behaves.

@Kosai106
Copy link
Owner

Kosai106 commented Jan 6, 2020

@patbl Would this be a more suitable change for you? #11

The result would now look like this:

data = [
  { 1: "en", 2: "to", 3: "tre" },
  { one: "un", two: "deux", three: "trois" },
  { "weights" => ["pound", "kilogram"], "lengths" => ["meter", "mile"] },
  { de: { one: "eins", two: "zwei", three: "drei" } }
]

@Kosai106 Kosai106 reopened this Jan 6, 2020
@chabgood
Copy link

You're right on the part about symbols not being able to start with a number, that was an oversight on my part. However I'd say it's a bit extreme to demand that everything should be revised based off of that.

As for your second point, if doing this would cause issues with your code, (Doesn't in mine) then just don't run the command on the affected lines. Simple.

When you say run the command, what command is that?

@Kosai106
Copy link
Owner

When you say run the command, what command is that?

The replace ruby syntax command you get when installing the plugin.
If you have a line highlighted, it will only replace the syntax on that line.

Screenshot 2021-12-14 at 10 32 38

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants