> On Jul 10, 2016, at 10:30 PM, Xiaodi Wu <[email protected]> wrote:
> 
> Questions/comments--
> 
> What's your use case for these?
> 
> For proposed literals like `point`, I'm having trouble visualizing how that 
> could be literally represented. Since the difference between one point and 
> another is its coordinate, would we just see a point floating on the screen?
> 
> Something like `size` seems ill-suited for literal representation, as opposed 
> to a shape (e.g. rectangle). Why is it a two-dimensional size anyway? Also, 
> since literals have no type, is there any scenario in which a `size` literal 
> of a certain width and height and a `point` literal with a certain x and y 
> coordinate are meaningfully different?
> 
> Finally, several of these look like string literals with types. For instance, 
> `unicode` seems to reflect a desire to refer to characters by their official 
> names. Perhaps that could be proposed instead as a new escaping syntax for 
> strings? Something like `let string = "\u{{DOG FACE}}"` might be pretty handy.

It doesn't have to be "represented". It can be used as `#literal.point(x: 3.5, 
y: 2.0)` without any "pretty" picture.

A literal offers a typeless universal value that can be interpreted by a 
conforming type as a representation of itself, so you can have:

let x: CGPoint = #literal.point(x: 3.5, y: 2.0)
let x: NSPoint = #literal.point(x: 3.5, y: 2.0)
let x: float2 = #literal.point(x: 3.5, y: 2.0)

-- E


_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to