Proposal: Unicode visualization annotations in declarations.


(Amir Michail) #1

Example source:

let alpha/𝛼 = 5
print(“alpha=\(alpha)”)

An IDE/editor that understands these visualization annotations would show this source as:

let alpha/𝛼 = 5
print(“alpha=\(𝛼)”)

Moving the cursor over 𝛼 would tell you in the status bar that this is a visualization for “alpha”.

Note that in the source, the unicode character only appears in the visualization annotation.

Here’s another example:

enum Suit { case Heart/:heart:, Diamond/♢, Spade/:spades:︎, Club/:clubs:︎ }
let x = Suit.Heart

In an IDE/editor that supports visualization annotations, the following would be shown:

enum Suit { case Heart/:heart:, Diamond/♢, Spade/:spades:︎, Club/:clubs:︎ }
let x = Suit.:heart:


(Sune Foldager) #2

What do we gain by this? Swift is a modern language with unicode source file support. If you use those, it may sometimes mean it’s difficult to edit programs on a more limited system, but

a) You don’t have to use those symbols in your own code.
b) Is that concern really worth adding extra syntax for, like this?

I don’t think so myself.

-Sune

···

On 16 Jan 2016, at 20:51, Amir Michail via swift-evolution <swift-evolution@swift.org> wrote:

Example source:

let alpha/𝛼 = 5
print(“alpha=\(alpha)”)

An IDE/editor that understands these visualization annotations would show this source as:

let alpha/𝛼 = 5
print(“alpha=\(𝛼)”)

Moving the cursor over 𝛼 would tell you in the status bar that this is a visualization for “alpha”.

Note that in the source, the unicode character only appears in the visualization annotation.

Here’s another example:

enum Suit { case Heart/:heart:, Diamond/♢, Spade/:spades:︎, Club/:clubs:︎ }
let x = Suit.Heart

In an IDE/editor that supports visualization annotations, the following would be shown:

enum Suit { case Heart/:heart:, Diamond/♢, Spade/:spades:︎, Club/:clubs:︎ }
let x = Suit.:heart:

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution