首页 \ 问答 \ 重新定义中缀操作符(Redefine the infix operators)

重新定义中缀操作符(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 be 1 * 2 and since ( * ) = (/), it will be then 1 / 2 and since (/) = (-), then it will be 1-2, so on so forth. Am I right?


Second, will the result of 5 + 4 / 1 be 15, 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 be 1 * 2 and no more transform, so 5 + 4 / 1 should be 5 * 4 -1, right? then the answer is 19. Am I correct?


原文:https://stackoverflow.com/questions/13686223
更新时间:2023-06-29 09:06

最满意答案

通常这是由约定来管理的。 运行在端口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 / 465的GMail发送电子邮件的示例。 稍微调整下面的代码应该可以工作! using System.Web.Mail; using System; public class MailSender { public static bool SendEmail( string pGmailEmail, string pGmailPassword, string pTo, string pSubject, ...
  • 邮件客户端在连接时必须知道隐式SSL是否正在使用,因为它负责使用ClientHello消息启动SSL握手。 它如何决定这取决于客户。 端口号是一个很好的提示,但是在某些UI中也可能有一个复选框,即使在使用标准(未受保护的)端口号时也会强制它。 有安全邮件的IANA注册端口号,但某些ISP可能使用其他端口。 IMAP / SSL:993 POP3 / SSL:995 SMTP / SSL通常在端口465上提供,但这没有注册,并且不太常见,因为SMTP代理广泛支持对显式SSL的支持。 服务器可以使用特定于协议的 ...
  • 使用不同的端口号进行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有多久了。 由于加载模块失败 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握手期间 ...
  • 到端口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 ...
  • 从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_ *函数的文档:您不应使用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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)