1

構造体の外で使用するために、構造体内で中置演算子を宣言したいと思います。しかし、構造が開かれたとしても、構造の外側に「固定性」が認識されないようです。Poly/ML を使用した例を次に示します。

> structure A = struct infix 6 ++ fun a ++ b = a + b end;
structure A: sig val ++: int * int -> int end
> 1 A.++ 2;
poly: : error: Type error in function application.
   Function: 1 : int
   Argument: A.++ : int * int -> int
   Reason: Value being applied does not have a function type
Found near 1 A.++ 2
Static Errors
> let open A in 1 ++ 2 end;
poly: : error: Type error in function application.
   Function: 1 : int
   Argument: ++ : int * int -> int
   Reason: Value being applied does not have a function type
Found near let open A in 1 ++ 2 end
Static Errors

これは標準 ML の制限ですか?

4

1 に答える 1