简体   繁体   English

F#中的“bigint”究竟是什么?

[英]What exactly is “bigint” in F#?

I understand that bigint is not a function but rather a type constructor. 我知道bigint不是一个函数,而是一个类型构造函数。 That's why this fails: 这就是失败的原因:

// Won't compile
let foo = 10 |> bigint

I understand that I can create a new function which accepts an integer and returns a bigint , and then the pipeline operator will work. 我知道我可以创建一个接受整数并返回bigint的新函数,然后管道运算符就可以工作了。

However, I don't understand why this works: 但是,我不明白为什么会这样:

let bar = bigint 10

If bigint is a type constructor, why don't I need new ? 如果bigint是一个类型构造函数,为什么我不需要new Where exactly is bigint defined as an alias to System.Numerics.BigInteger's constructor? 究竟哪个bigint被定义为System.Numerics.BigInteger的构造函数的别名?

bigint is type abberviation for System.Numerics.BigInteger so when you type bigint是System.Numerics.BigInteger的类型abberviation,因此当您键入时

let x = bigint 10

you actually create instance of BigInteger. 你实际上创建了BigInteger的实例。 In F# new is optional in constructors, basically it should be used when creating instances of types that implement IDisposable 在F#中, new在构造函数中是可选的,基本上它应该在创建实现IDisposable的类型的实例时使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM