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

multiline quotes using """ ... """ #71

Closed
StefanKarpinski opened this issue Jun 21, 2011 · 1 comment
Closed

multiline quotes using """ ... """ #71

StefanKarpinski opened this issue Jun 21, 2011 · 1 comment
Labels
speculative Whether the change will be implemented is speculative

Comments

@StefanKarpinski
Copy link
Member

Stolen from Python but with some differences:

function jabberwock()
  """
  'Twas brillig, and the slithy toves
  Did gyre and gimble in the wabe;
  All mimsy were the borogoves,
  And the mome raths outgrabe.
  """
end

julia> print(jabberwock())
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

The point of the """ construct is to make it easy to embed snippets of text or code in a readable, nice way inside of Julia code. To that end, it is similar to here documents as well as Python's multiline strings, which use the same delimiters. However, a couple of semantics make these easier to use:

  • If the initial """ is on a line followed only by whitespace, that whitespace (including newline) will be stripped.
  • Lines following the opening """ token must begin with the same indentation sequence (identical whitespace characters).
  • The common indentation will be stripped from each follow-up line.

After these transformations are applied, all normal string interpretation is performed. Moreover, you can prefix """ with an identifier as you can with " strings to invoke macro-based custom-string forms. Thus, a Q""" multiline string has no interpolation performed and a r""" is a multiline regex literal (should maybe automatically switch on some flags).

@StefanKarpinski
Copy link
Member Author

This a duplicate issue caused by some sort of github fuckup. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

1 participant