Skip to content

Multi-level values #2

@ctxppc

Description

@ctxppc

Silica should support associated values with types with finite inhabitants, more specifically enum types whose cases either don’t have associated values or whose associated values have value types with finite inhabitants (recursively), and the Bool type (with inhabitants false and true). It should generate localised string entries for all possible combinations. For example,

enum CarColour {
    case red
    case blue
}

enum Vehicle : LocalisableString {
    case bus(seats: Int, isDoubleDecker: Bool)
    case car(colour: CarColour, doors: Int)
}

should map to the localised string entries (with localiser-provided values):

"Vehicle.bus(seats: %ld, isDoubleDecker: false)" = "A normal bus with %ld seats"
"Vehicle.bus(seats: %ld, isDoubleDecker: true)" = "A double-decker with %ld seats"
"Vehicle.car(colour: .red, doors: %ld)" = "A red %ld-door car"
"Vehicle.car(colour: .blue, doors: %ld)" = "A blue %ld-door car"

If #1 is implemented, this support should be also extended to properties with value types with finite inhabitants.

Silica should perform an exhaustiveness check and limit the number of combinations (outputting a warning when the limit is exceeded). An option should be made available to change the limit (or outright disable it).

A future direction is to allow associated values with value types conforming to LocalisableString (possibly with infinite inhabitants).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions