[Discussion] Type hierarchy translation consistency


(Adrian Zubarev) #1

Is this some wrong api translation or something?

extension String {

    /// The index type for subscripting a string.
    public typealias Index = String.CharacterView.Index

    /// A type used to represent the number of steps between two `String.Index`
    /// values, where one value is reachable from the other.
    ///
    /// In Swift, *reachability* refers to the ability to produce one value from
    /// the other through zero or more applications of `index(after:)`.
    public typealias IndexDistance = IndexDistance
IndexDistance = IndexDistance really?

Shouldn’t this look like

public typealias IndexDistance = public typealias IndexDistance = String.CharacterView.IndexDistance?
Don’t get me wrong, Xcode is able to tell me that by cmd+click in the right IndexDistance but this translation is ugly.

Otherwise I also could write

public typealias Index = Index
which looks very ugly.

Is this a bug? Current snapshot bug?
Should we propose for more consistency or is this something that the devs are working on?

···

--
Adrian Zubarev
Sent with Airmail


(Adrian Zubarev) #2

Just looked up the current implementation of this:

extension String {
  /// The index type for subscripting a string.
  public typealias Index = CharacterView.Index

  /// A type used to represent the number of steps between two `String.Index`
  /// values, where one value is reachable from the other.
  ///
  /// In Swift, *reachability* refers to the ability to produce one value from
  /// the other through zero or more applications of `index(after:)`.
  public typealias IndexDistance = CharacterView.IndexDistance
So the whole thing is somehow a wrong translation I’d guess.

Should I file a bug?

···

--
Adrian Zubarev
Sent with Airmail

Am 11. Juni 2016 um 17:02:15, Adrian Zubarev (adrian.zubarev@devandartist.com) schrieb:

Is this some wrong api translation or something?

extension String {

    /// The index type for subscripting a string.
    public typealias Index = String.CharacterView.Index

    /// A type used to represent the number of steps between two `String.Index`
    /// values, where one value is reachable from the other.
    ///
    /// In Swift, *reachability* refers to the ability to produce one value from
    /// the other through zero or more applications of `index(after:)`.
    public typealias IndexDistance = IndexDistance
IndexDistance = IndexDistance really?

Shouldn’t this look like

public typealias IndexDistance = public typealias IndexDistance = String.CharacterView.IndexDistance?
Don’t get me wrong, Xcode is able to tell me that by cmd+click in the right IndexDistance but this translation is ugly.

Otherwise I also could write

public typealias Index = Index
which looks very ugly.

Is this a bug? Current snapshot bug?
Should we propose for more consistency or is this something that the devs are working on?

--
Adrian Zubarev
Sent with Airmail


(Dmitri Gribenko) #3

Yes, please!

Dmitri

···

On Sun, Jun 12, 2016 at 3:33 AM, Adrian Zubarev via swift-evolution <swift-evolution@swift.org> wrote:

Just looked up the current implementation of this:

extension String {
  /// The index type for subscripting a string.
  public typealias Index = CharacterView.Index

  /// A type used to represent the number of steps between two
`String.Index`
  /// values, where one value is reachable from the other.
  ///
  /// In Swift, *reachability* refers to the ability to produce one value
from
  /// the other through zero or more applications of `index(after:)`.
  public typealias IndexDistance = CharacterView.IndexDistance

So the whole thing is somehow a wrong translation I’d guess.

Should I file a bug?

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/