Skip to content
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

Parinfer question #51

Closed
oakmac opened this issue Feb 25, 2016 · 7 comments
Closed

Parinfer question #51

oakmac opened this issue Feb 25, 2016 · 7 comments

Comments

@oakmac
Copy link
Owner

oakmac commented Feb 25, 2016

FYI - @phillc73 and @otherjoel, I moved your conversation to this new Issue since it was unrelated to Issue #9. Thanks :)

@phillc73 's original question:


Just starting out with Clojure (first attempt at any Lisp language) so I hope this is not user error and I'm posting in the right Issue.

Following the "do" example in the Brave and True Clojure book, Parinfer in Atom wants to do this:

(if false
  (do (println "Yes! True!")) 
  "True"
  (do (println "No")) 
  "False")

Rather than:

(if false
  (do (println "Yes! True!")
  "True!")
  (do (println "No")
  "False"))
@oakmac
Copy link
Owner Author

oakmac commented Feb 25, 2016

@otherjoel 's response:


Parinfer in Atom wants to do this [...] rather than this [...]

Yes, this is expected/desired behaviour. Because "True" in your example is at the same indent level as the line above it. So Parinfer reasons they must be siblings in the list and adjusts parentheses to reflect this. (same goes for your "False" line.)

If you indent "True" any further past the indent level of the line above it, Parinfer will see that it is supposed to be a sibling of (println "Yes! True") instead of a sibling of (do ...) and it will make the parenthesis reflect this. Note that this is how the indentation appears in the original example from the book you linked.

The above assumes you're in Indent Mode (where you change indentation manually/directly and Parinfer handles the parens in the background, matching them to the indentation).

@oakmac
Copy link
Owner Author

oakmac commented Feb 25, 2016

Also wanted to add that 1) this is a great question, and 2) @otherjoel 's answer is spot on

@phillc73 - You may want to look at Issue #46 as well.

@phillc73
Copy link

Thanks @otherjoel and @oakmac. I see now. Looks like it was user error, so might be just best to close. I still have a lot of reading to do!

@oakmac
Copy link
Owner Author

oakmac commented Feb 25, 2016

No worries; you won't regret learning Clojure :)

If you haven't checked out the main Parinfer page, that might be worth doing. The short version is that Parinfer is just a plugin to your text editor that helps you write Lisp code by balancing parenthesis based on indentation (like Python or CoffeeScript). It doesn't fundamentally change the language or syntax; it's just a "human helper" ;)

@oakmac oakmac closed this as completed Feb 25, 2016
@phillc73
Copy link

@oakmac I've spent a lot of time in debugging hell using RStudio's Shiny Web Framework where mismatched parenthesis are the number one cause of application errors.

When I was investigating which language to explore next, and read about Parinfer, it was a massive plus for Clojure.

@oakmac
Copy link
Owner Author

oakmac commented Feb 25, 2016

When I was investigating which language to explore next, and read about Parinfer, it was a massive plus for Clojure.

I'm sure @shaunlebron will be glad to hear that :)

@otherjoel
Copy link

👍🏻

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

No branches or pull requests

3 participants