0
我读this文章,我遇到以下两个函数来了:什么是Swift中的'const'关键字?
// Sequence actions, discarding the value of the second argument
func <* <A, B>(p: Parser<A>, q: Parser<B>) -> Parser<A> {
return const <^> p <*> q
}
// Sequence actions, discarding the value of the first argument
func *> <A, B>(p: Parser<A>, q: Parser<B>) -> Parser<B> {
return const(id) <^> p <*> q
}
什么const
和const(id)
?我猜他们是某种价值观,但有什么价值?它们是隐式的左侧还是右侧操作数? (这只是在黑暗中拍摄的照片)。我找不到任何有关它的信息。
我相信这是他的解析器函数,而不是基金会的一部分。 – Rob
@Rob啊,这是有道理的! –
https://github.com/tryswift/TryParsec/blob/4dc2cadc23311fc27dbcbd108727bab46905e229/Sources/TryParsec/Prelude.swift#L7 – Hamish