{"action":"reopened","issue":{"url":"https://api.github.com/repos/tomjakubowski/json_macros/issues/3","labels_url":"https://api.github.com/repos/tomjakubowski/json_macros/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/tomjakubowski/json_macros/issues/3/comments","events_url":"https://api.github.com/repos/tomjakubowski/json_macros/issues/3/events","html_url":"https://github.com/tomjakubowski/json_macros/issues/3","id":48709657,"number":3,"title":"Why a syntax extension?","user":{"login":"dfreeman","id":108688,"avatar_url":"https://avatars.githubusercontent.com/u/108688?v=3","gravatar_id":"","url":"https://api.github.com/users/dfreeman","html_url":"https://github.com/dfreeman","followers_url":"https://api.github.com/users/dfreeman/followers","following_url":"https://api.github.com/users/dfreeman/following{/other_user}","gists_url":"https://api.github.com/users/dfreeman/gists{/gist_id}","starred_url":"https://api.github.com/users/dfreeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfreeman/subscriptions","organizations_url":"https://api.github.com/users/dfreeman/orgs","repos_url":"https://api.github.com/users/dfreeman/repos","events_url":"https://api.github.com/users/dfreeman/events{/privacy}","received_events_url":"https://api.github.com/users/dfreeman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-11-13T23:32:05Z","updated_at":"2015-02-01T02:39:05Z","closed_at":null,"body":"Apologies if the answer to this is of the form \"well obviously...\" -- I don't have a ton of experience working with Rust yet. I'm interested in understanding why you implemented this as a syntax extension instead of just using `macro_rules`.\r\n\r\nFor comparison, I've got a little helper I use for testing in a project that (I think) yields pretty similar results:\r\n\r\n```rust\r\nuse serialize::json::{mod, ToJson};\r\n\r\nmacro_rules! json {\r\n  (null) => (json::Null);\r\n  ([ $($values:tt),* ]) => (json::List(vec![ $(json!($values)),* ]));\r\n  ({ $($keys:expr : $values:tt),* }) => ({\r\n    let kv_pairs = vec![ $(($keys.to_string(), json!($values))),* ];\r\n    json::Object(kv_pairs.into_iter().collect())\r\n  });\r\n  ($ex:expr) => ($ex.to_json());\r\n}\r\n```\r\n\r\nA couple interesting bits:\r\n - Negative numbers are a problem here, too (and the parens workaround works)\r\n - Every numeric literal needs a suffix, e.g. `json!({ \"list\": [1i, 2, 3] })` won't work. It has to be one of:\r\n  - `json!({ \"list\": [1i, 2i, 3i] })`\r\n  - `json!({ \"list\": (vec![1i, 2, 3]) })`\r\n - String slice literals don't work out of the box (since they don't have a `ToJson` impl), but it's easy enough to create a wrapper trait with impls for `T: ToJson` and `&str`.\r\n\r\nAre you planning on extending the syntax (e.g. for expression splicing) in ways that would be more difficult to handle with `macro_rules`?"}}