Skip to content

Conversation

@tecosaur
Copy link
Member

Closes #28 (which see).

Will merge shortly if everything appears to be in order.

In 5dd8b9e we reserved the use of ":" in styled regions in
anticipation of the potential use of a style and format construction
"{style:content:format}" inspired by Python's f-strings.

It has since become apparent that this causes more headaches than
anticipated in Julia. The primary reason for this is the different
syntactic meaning that ":" has in Julia compared to Python. While in
Python ":" serves as a block terminator (used after: if, for, while,
def, etc.), in Julia ":" can appear /within/ expressions (namely with
ranges and indexing), for example:

  1:2:9
  m[1, :]
  :(1 + 2)

This means that when formatting an expression, copy-paste is now subtly
error-prone as not just quotes but colons will need to be escaped.

This adds to the minor, but present, annoyance of having to escape ":"
in "{style:content}" constructions, and in my mind tips the scales
towards the prospective "{style:content:fmt}" syntax no longer being
worth it.

A more promising alternative is to go with something like "${fmt:expr}".
By both this and "{style:content}" having a single delimiting colon, we
can simply read everything until the paired closing curly parentheses at
the end of the form as expr/content. The use of "$" in "${fmt:expr}" is
also evocative of Julia's $-interpolation syntax, which is appropriate
given that expr would be evaluated.

While a formating syntax, let alone system, is not decided on at this
stage, I think we can safely un-reserve the colon.
@tecosaur
Copy link
Member Author

Given a week's gone by with no comment, I'll go ahead with this now 🙂

@tecosaur tecosaur merged commit 60c956f into main Jan 30, 2024
@tecosaur tecosaur deleted the remove-second-colon branch January 30, 2024 11:42
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

Successfully merging this pull request may close these issues.

Remove support for escaped-colon syntax in favor of using ${} for formatting in the future

1 participant