奇怪的`int_of_string`调用?

z_a*_*xis 1 ocaml

以下代码片段来自ocsigen源代码.我不理解用两个参数调用的"int_of_string":

 try
    let dppos = String.index ss':'
        and len = String.length ss in                     
        let host = String.sub ss 0 dppos                  
        and port =                                        
            match String.sub ss (dppos+1) ((len - dppos) - 1) with
                "*" -> None
                | p -> Some (int_of_string "host" p)
             in host, port                                                           
  with                                                
      | Not_found -> ss, None
      | Failure _ ->                                    
          raise (Config_file_error "bad port number")
Run Code Online (Sandbox Code Playgroud)

我在顶层测试它,它正常报告错误.

祝商祺!

Ash*_*she 5

请注意该文件的顶部:

let blah_of_string f tag s =
  try
    f (String.remove_spaces s 0 ((String.length s) -1))
  with Failure _ -> raise (Ocsigen_config.Config_file_error
                             ("While parsing <"^tag^"> - "^s^
                                " is not a valid value."))

let int_of_string = blah_of_string int_of_string
let float_of_string = blah_of_string float_of_string
Run Code Online (Sandbox Code Playgroud)

即它根本不是Pervasives.int_of_string!