重新定义中缀操作符(Redefine the infix operators)
我正在学习Jason Hickey的Objective Caml简介 。
只是有一个关于重新定义中缀操作符的问题 。
所以在书中有这样一段话:
# let (+) = ( * ) and (-) = (+) and ( * ) = (/) and (/) = (-);; val + : int > int > int = <fun> val - : int > int > int = <fun> val * : int > int > int = <fun> val / : int > int > int = <fun> # 5 + 4 / 1;; -: **int = 15**
首先,这些重新定义是如何工作的?
对我来说,似乎函数运行在一种无限循环中,因为所有的操作都被重新定义和连接。
例如,如果我做
1+2
,那么它将是1 * 2
并且因为( * ) = (/)
,它将是1 / 2
并且因为(/) = (-)
,那么它将是1-2
,等等等等。 我对吗?
其次,
5 + 4 / 1
的结果是15
,即使这些函数在重定义中只执行了一步?因此,假定重新定义将进一步执行,即
1 + 2
将仅为1 * 2
并且不再有变换,所以5 + 4 / 1
应该是5 * 4 -1
,对吗? 那么答案是19
。 我对么?I am learning Jason Hickey's Introduction to Objective Caml.
Just have a question about Redefine the infix operators.
So in the book, there is such a paragraph:
# let (+) = ( * ) and (-) = (+) and ( * ) = (/) and (/) = (-);; val + : int > int > int = <fun> val - : int > int > int = <fun> val * : int > int > int = <fun> val / : int > int > int = <fun> # 5 + 4 / 1;; -: **int = 15**
First, how does these redefinition work?
To me, it seems the functions are running in a kind of indefinite loop, because all the operations seem redefined and connected.
for example, if I do
1+2
, then it will be1 * 2
and since( * ) = (/)
, it will be then1 / 2
and since(/) = (-)
, then it will be1-2
, so on so forth. Am I right?
Second, will the result of
5 + 4 / 1
be15
, even if the functions are executed only one step further in the redefinition?So assume the redefinition will be execute one step further, i.e.,
1 + 2
will only be1 * 2
and no more transform, so5 + 4 / 1
should be5 * 4 -1
, right? then the answer is19
. Am I correct?
原文:https://stackoverflow.com/questions/13686223
最满意答案
通常这是由约定来管理的。 运行在端口25上的SMTP(正常情况)使用显式SSL。 运行在端口465上的SMTPS使用隐式SSL。 在端口587上运行的邮件提交使用显式SSL。
为了确定,telnet到端口,如“telnet mail.example.com 25”。 如果您看到服务器标识自己的纯文本横幅,那么您正在处理显式SSL。 如果您连接成功并且什么也没看到,那么您正在处理隐式SSL。
Ordinarily this is governed by convention. SMTP running on port 25 (the normal case) uses explicit SSL. SMTPS running on port 465 uses implicit SSL. Mail submission running on port 587 uses explicit SSL.
To tell for sure, telnet to the port, as in "telnet mail.example.com 25". If you see a plain text banner where the server identifies itself, then you are dealing with explicit SSL. If you connect successfully and see nothing, then you are dealing with implicit SSL.
相关问答
更多-
如何通过SSL SMTP与.NET Framework发送电子邮件?(How can I send emails through SSL SMTP with the .NET Framework?)[2022-07-31]
以下是如何通过也使用SSL / 465的GMail发送电子邮件的示例。 稍微调整下面的代码应该可以工作! using System.Web.Mail; using System; public class MailSender { public static bool SendEmail( string pGmailEmail, string pGmailPassword, string pTo, string pSubject, ... -
SMTP客户端如何确定是使用显式还是隐式SSL(How do SMTP clients determine whether to use Explicit or Implicit SSL)[2022-12-28]
邮件客户端在连接时必须知道隐式SSL是否正在使用,因为它负责使用ClientHello消息启动SSL握手。 它如何决定这取决于客户。 端口号是一个很好的提示,但是在某些UI中也可能有一个复选框,即使在使用标准(未受保护的)端口号时也会强制它。 有安全邮件的IANA注册端口号,但某些ISP可能使用其他端口。 IMAP / SSL:993 POP3 / SSL:995 SMTP / SSL通常在端口465上提供,但这没有注册,并且不太常见,因为SMTP代理广泛支持对显式SSL的支持。 服务器可以使用特定于协议的 ... -
如何知道我的服务器是否使用SSL(使用Twisted)(How to know if my server is using SSL or not (with Twisted))[2022-01-14]
使用不同的端口号进行SSL连接。 这就是HTTP / HTTPS的使用方式。 要么 在协议中定义一个命令,根据能力协商将连接转换为SSL,例如STARTTLS 。 这是在SMTP中实现同样的一种方式。 Use a different port number for SSL connections. This is how HTTP / HTTPS are used. Or Define a command in your protocol to transform the connection into S ... -
安装Net :: SMTP :: SSL(Installing Net::SMTP::SSL)[2023-04-20]
我最近意识到当我尝试调查失败的脚本时, Net :: SMTP :: SSL有多久了。 由于加载模块失败 no strict 'refs'; foreach ( keys %Net::SMTP:: ) { next unless defined *{$Net::SMTP::{$_}}{CODE}; *{$_} = \&{"Net::SMTP::$_"}; } 在Net/SMTP/SSL.pm : [~/tmp/Net-SMTP-SSL-1.01]> prove -vb t/test.t t ... -
通常这是由约定来管理的。 运行在端口25上的SMTP(正常情况)使用显式SSL。 运行在端口465上的SMTPS使用隐式SSL。 在端口587上运行的邮件提交使用显式SSL。 为了确定,telnet到端口,如“telnet mail.example.com 25”。 如果您看到服务器标识自己的纯文本横幅,那么您正在处理显式SSL。 如果您连接成功并且什么也没看到,那么您正在处理隐式SSL。 Ordinarily this is governed by convention. SMTP running on ...
-
有多个问题,让我们尝试逐一解决它们: 为什么删除工作,但上传,下载和列表不? FTP协议使用两个单独的连接。 第一个(称为控制连接 )用于具有简单响应的命令 - 例如登录,删除,make目录等。通常它在端口21上运行。 当FTP客户端请求数据传输操作时,建立另一个连接(称为数据连接 )。 在活动模式下,FTP服务器连接到客户端,在被动模式下,客户端连接到服务器。 如果此连接被防火墙阻止,则数据传输操作将失败。 数据传输操作是上传,下载和目录列表 。 这就是删除工作而列表没有的原因。 服务器返回一个地址以响应 ...
-
SSL和证书(SSL and certificates)[2022-02-16]
如果服务器未通过身份验证,那么您确实无法拥有私人频道 - 中间人偷听,在两个合法方之间转发流量太容易了。 如果您没有隐私或身份验证,为什么要使用SSL? 实际上存在“匿名”模式,其中公钥密码术用于同意加密密钥,但客户端或服务器都不提供证书; 但是,我从来没有见过他们使用过,可能是因为他们无法解决中间人偷听攻击。 是的,服务器提供证书。 服务器可以向客户端请求证书。 客户端可以使用证书进行响应,或忽略该请求。 如果请求被忽略,服务器可以选择继续使用匿名客户端,或终止连接。 客户端和服务器的角色在SSL握手期间 ... -
到端口587的SMTP连接开始未加密。 如果服务器支持,可以在SMTP会话中使用STARTTLS命令稍后关闭加密。 openssl支持某些协议(包括SMTP)的STARTTLS 。 它需要-starttls smtp命令行选项,如https://stackoverflow.com/a/14645854/2139766中所述 Outlook.com似乎不支持smtps: http : //windows.microsoft.com/en-us/windows/outlook/send-receive-from ...
-
如何在双绞线SSL客户端中验证SSL服务器证书(How to validate the SSL server certificate in twisted SSL client)[2022-07-31]
从Twisted 14.0开始, optionsForClientTLS是执行此操作的最佳方式: from twisted.internet.ssl import optionsForClientTLS from twisted.internet.endpoints import SSL4ClientEndpoint ctx = optionsForClientTLS(hostname=u"example.com") endpoint = SSL4ClientEndpoint(reactor, host, ... -
SSL CONNECT产生-1错误(SSL CONNECT produces -1 ERROR)[2022-03-23]
请阅读SSL_ *函数的文档:您不应使用strerror,而应使用SSL_get_error(retVal)来获取SSL_connect的SSL错误代码。 根据错误代码,您需要使用ERR_get_error来访问错误队列,并使用ERR_error_string来获取错误的字符串表示。 Please read the documentation of the SSL_* functions: You should not use strerror, but SSL_get_error(retVal) to g ...