У меня есть фрагмент котлинского кода, где первый и вторичный конструктор ежеминутно отличается, смотри нижекотлинский - Вторичный конструктор, который отличается от одного аргумента
class InstructionPrototype constructor(
val iname: String,
val opcode: Int,
val mnemonicExample: String,
val numericExample: Int,
val description: String,
val format: Format,
val pattern: Pattern,
var type: Type? = null,
var rt: Int? = null,
var funct: Int? = null,
var conditions: Array<(n: Int) -> String?>? = null) {
constructor(
iname: String,
opcode: Int,
mnemonicExample: String,
numericExample: Int,
description: String,
format: Format,
pattern: Pattern,
type: Type?,
rt: Int?,
funct: Int?,
condition: (n: Int) -> String?
): this(iname, opcode, mnemonicExample, numericExample, description,
format, pattern, type, rt, funct, arrayOf(condition)) {
}
можно ли уменьшить подробность этого через некоторый язык построить? Я думал об алгебраических типах данных, но это не очень хорошо подходило - оно натолкнулось на «хаки».