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

Automatic dedent FTW #5135

Closed
gitfoxi opened this issue Dec 14, 2013 · 10 comments
Closed

Automatic dedent FTW #5135

gitfoxi opened this issue Dec 14, 2013 · 10 comments
Labels
docs This change adds or pertains to documentation

Comments

@gitfoxi
Copy link
Contributor

gitfoxi commented Dec 14, 2013

object = 
"""    {
    "hi" : "I'm an object",
    }
"""
println(object)

object = 
"""{
    "hi" : "I'm an object",
    }"""
println(object)
    {
    "hi" : "I'm an object",
    }

{
"hi" : "I'm an object",
}

This seems like a feature I could be friends with if it just introduced itself rather than jumping me in the park while I was walking home drunk.

The rule seems obscure: If you endquote on a line containing something then you get auto-dedent. If you endquote at the beginning of a newline then you don't dedent. Is that it?

To be clear, maybe you want a dedent quote d""" and the regular """ doesn't dedent. Dedent. It's kind of fun to say. Dedent.

@pao
Copy link
Member

pao commented Dec 14, 2013

The feature is intentional (as you suspect), and was introduced some time before the Pkg2 rewrite if you want to dive and see if there was any discussion on how it should work. I want to say there was, but I'm falling asleep in my chair right now so won't be looking it up.

May just need clearer docs?

@stevengj
Copy link
Member

This seems like a misfeature to me....why should a literal string implicitly ignore whitespace?

@StefanKarpinski
Copy link
Member

Because this is typically used to embed text within code and the code tends to be indented but you don't want the text to be indented. That leads to very awkward code where the string literals are flush left in the middle of indented code. Automatically dedenting the string literal content is very convenient.

@stevengj
Copy link
Member

Okay...

@pao
Copy link
Member

pao commented Dec 18, 2013

$ cat - <<-EOF
    This feature is not unprecedented.
    It has been implemented before in other contexts.
EOF

@ihnorton
Copy link
Member

Comment/re-open if there is a need to revisit this.

@nolta
Copy link
Member

nolta commented Jan 14, 2015

Why was this closed? AFAICT, this is still undocumented.

@stevengj stevengj reopened this Jan 14, 2015
@ihnorton
Copy link
Member

Ok. Can we just document it then and tell people to define their own R_str
macro if they want something else? (I thought there was broad support for
bringing that macro back...)

On Wed, Jan 14, 2015 at 11:40 AM, Steven G. Johnson <
[email protected]> wrote:

Reopened #5135 #5135.


Reply to this email directly or view it on GitHub
#5135 (comment).

@stevengj
Copy link
Member

Certainly we should document it. Introducing other macros seems like an orthogonal issue that should be debated elsewhere.

@nolta
Copy link
Member

nolta commented Sep 21, 2015

#13246

@nolta nolta closed this as completed Sep 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

6 participants