キーワードを使用して、and
相互に再帰的な関数定義を設定できます。相互再帰型にも使用できますand
が、型と関数の間に相互再帰関係がある場合はどうなるでしょうか。関数を型のメンバーにする唯一のオプションですか、それともここに似たものを使用できand
ますか?
編集:私がやろうとしていることを説明したいと思う単純化された疑似例を追加する
// A machine instruction type
type Instruction = Add | CallMethod int (* method ID *) | ...
// A class representing a method definition
type MethodDef (fileName : string) =
member x.Params with get () = ...
member x.Body with get() =
let insts = readInstructions fileName
Array.map toAbstractInst insts
// a more abstract view of the instructions
and AbstractInstruction = AbstAdd | AbstCallMethod MethodDef | ...
// a function that can transform an instruction into its abstract form
let toAbstractInst = function
| Add -> AbstAdd
| CallMethod methodId -> AbstCallMethod (somehowResolveId methodId)
| ...
したがって、再帰的な関係がかなり間接的に設定されていることがわかります: MethodDef <-> AbstractInst AND MethodDef -> toAbstractInst -> AbstractInstruction (ここで、-> は「依存」を意味します)