我在openssl源代码中注意到一个奇怪的习惯用语,在这里重复如下:
if ((in == NULL) && (passwds == NULL)) {
if (1) { (* <---- HERE *)
#ifndef OPENSSL_NO_UI
/* build a null-terminated list */
static char *passwds_static[2] = { NULL, NULL };
passwds = passwds_static;
if (in == NULL)
if (EVP_read_pw_string
(passwd_malloc, passwd_malloc_size, "Password: ",
!(passed_salt || in_noverify)) != 0)
goto end;
passwds[0] = passwd_malloc;
} else {
#endif
BIO_printf(bio_err, "password required\n");
goto end;
}
}
Run Code Online (Sandbox Code Playgroud)
似乎这段代码相当于:
if ((in == NULL) && (passwds == NULL)) {
#ifndef …Run Code Online (Sandbox Code Playgroud) 我在OCaml中创建monad并需要编写它们,所以我创建了变换器.我使用Identity monad在变换器方面实现了常规monad:
module type MONAD = sig
type 'a m
val (>>=) : 'a m -> ('a -> 'b m) -> 'b m
val return : 'a -> 'a m
end
module Identity : MONAD = struct
type 'a m = 'a
let (>>=) m f = f m
let return x = x
end
module OptionT (M : MONAD) : MONAD with type 'a m := ('a option) M.m = struct
type 'a m = ('a option) M.m
let …Run Code Online (Sandbox Code Playgroud)