Back to all reviewers

Follow Swift naming conventions

tensorflow/swift
Based on 3 comments
Swift

Ensure code follows established Swift naming conventions and remains consistent with domain terminology: 1. Use standard Swift parameter labels (e.g., use `named:` instead of `called:`):

Naming Conventions Swift

Reviewer Prompt

Ensure code follows established Swift naming conventions and remains consistent with domain terminology:

  1. Use standard Swift parameter labels (e.g., use named: instead of called:): ```swift // Incorrect func expectOne(called name: String, among candidates: [T]) throws -> T { ... }

// Correct func expectOne(named name: String, among candidates: [T]) throws -> T { ... }


2. Organize functions as methods on relevant types when appropriate:
```swift
// Less idiomatic
public func operandNames(for inst: Instruction) -> [String]? { ... }

// More idiomatic
extension Instruction {
    public var operandNames: [String]? { ... }
}
  1. Use domain-specific terminology consistently (e.g., “operand names” not “registers” in SIL context)

  2. Avoid redundancy in type names, especially in enum cases: ```swift // Redundant public indirect enum Type { case addressType(_ type: Type) }

// Concise public indirect enum Type { case address(Type) } ```

  1. Maintain consistency with existing codebase conventions (e.g., using inst instead of instr for variables if that’s the established pattern)
3
Comments Analyzed
Swift
Primary Language
Naming Conventions
Category

Source Discussions