日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
詳解F#2.0中兩大運(yùn)行時(shí)的簡(jiǎn)單應(yīng)用

我們知道,F(xiàn)# 2.0 有面向 .NET Framework 2.0 和 .NET Framework 4 的兩個(gè)運(yùn)行時(shí)。此外,F(xiàn)# 2.0 還有一個(gè)面向Silverlight 的運(yùn)行時(shí)。

面向 .NET Framework 2.0 的 F# 2.0 運(yùn)行時(shí)的核心庫(kù) (FSharp.Core.dll) 將一些 API 包含在 System 命名空間中,這些 API 與 F# 開發(fā)所需的 .NET Framework 4 API 相同。例如 System.Numerics.BigInteger 和 System.Tuple 就是這樣。

Windows 操作系統(tǒng):

 
 
 
 
  1. E:\> gacutil -l FSharp.Core  
  2. Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1  
  3. 版權(quán)所有(C) Microsoft Corporation。保留所有權(quán)利。  
  4.  
  5. 全局程序集緩存包含下列程序集:  
  6.   FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL 
  7.   FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL 
  8.  
  9. 項(xiàng)目數(shù) = 2  
  10.  
  11. E:\> fsi.exe  
  12.  
  13. Microsoft(R) F# 2.0 Interactive 版本 4.0.30319.1  
  14. 版權(quán)所有(C) Microsoft Corporation。保留所有權(quán)利。  
  15.  
  16. 若要獲得幫助,請(qǐng)鍵入 #help;;  
  17.  
  18. > 8I.GetType().AssemblyQualifiedName;;  
  19. val it : string =  
  20.   "System.Numerics.BigInteger, System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
  21. > #quit;;  
  22.  
  23. E:\> c:  
  24. C:\> cd "\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime"  
  25. C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime> dir v2.0\FSharp.Core.dll v4.0\FSharp.Core.dll  
  26.  驅(qū)動(dòng)器 C 中的卷是 OS  
  27.  卷的序列號(hào)是 5ACA-EDB5  
  28.  
  29.  C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0 的目錄  
  30.  
  31. 2010/03/19  05:52           938,840 FSharp.Core.dll  
  32.                1 個(gè)文件        938,840 字節(jié)  
  33.  
  34.  C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0 的目錄  
  35.  
  36. 2010/03/19  05:52           895,832 FSharp.Core.dll  
  37.                1 個(gè)文件        895,832 字節(jié)  
  38.                0 個(gè)目錄  4,724,301,824 可用字節(jié)  
  39.  
  40. C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime> 

Linux 操作系統(tǒng):

 
 
 
 
  1. ben@ben-1520:~$ gacutil -l FSharp.Core  
  2. The following assemblies are installed into the GAC:  
  3. FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
  4. Number of items = 1 
  5. ben@ben-1520:~$ fsi.exe  
  6.  
  7. Microsoft (R) F# 2.0 Interactive build 2.0.0.0  
  8. Copyright (c) Microsoft Corporation. All Rights Reserved.  
  9.  
  10. For help type #help;;  
  11.  
  12. > 8I.GetType().AssemblyQualifiedName;;  
  13. val it : string =  
  14.   "System.Numerics.BigInteger, FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
  15. > #quit;;  
  16.  
  17. - Exit...  
  18. ben@ben-1520:~$ cd /usr/local/bin/FSharp-2.0.0.0/bin/ && ls -l FSharp.Core.dll  
  19. -rw-r--r-- 1 root root 938,840 2010-06-14 23:54 FSharp.Core.dll  
  20. ben@ben-1520:/usr/local/bin/FSharp-2.0.0.0/bin$  

使用 .NET Reflector 來查看:

讓我們琮看看下面的 test.fs 程序:

 
 
 
 
  1. 1:  open System;  
  2. 2:  printfn "OS  Version: %A" Environment.OSVersion  
  3. 3:  printfn "CLR Version: %A" Environment.Version  
  4. 4:  printfn "%s" (8I.GetType().AssemblyQualifiedName) 

在 Linux 操作系統(tǒng)下編譯和運(yùn)行(使用面向 .NET Framework 2.0 的 F# 2.0 運(yùn)行時(shí)):

 
 
 
 
  1. ben@ben-1520:~/work$ fsc.exe test.fs  
  2. Microsoft (R) F# 2.0 Compiler build 2.0.0.0  
  3. Copyright (c) Microsoft Corporation. All Rights Reserved.  
  4. ben@ben-1520:~/work$ fsc.exe --out:test2.exe --standalone test.fs  
  5. Microsoft (R) F# 2.0 Compiler build 2.0.0.0  
  6. Copyright (c) Microsoft Corporation. All Rights Reserved.  
  7. ben@ben-1520:~/work$ ls -l test*.exe  
  8. -rwxr-xr-x 1 ben ben 923,136 2010-08-15 14:25 test2.exe  
  9. -rwxr-xr-x 1 ben ben   4,608 2010-08-15 14:25 test.exe  
  10. ben@ben-1520:~/work$ ./test.exe  
  11. OS  Version: Unix 2.6.32.24  
  12. CLR Version: 2.0.50727.1433  
  13. System.Numerics.BigInteger, FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
  14. ben@ben-1520:~/work$ ./test2.exe  
  15. OS  Version: Unix 2.6.32.24  
  16. CLR Version: 2.0.50727.1433  
  17. System.Numerics.BigInteger, test2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 
  18. ben@ben-1520:~/work$  

上面的 test2.exe 使用 --standalone 參數(shù)編譯,表示以靜態(tài)方式將 F# 庫(kù)與依賴于此庫(kù)的所有引用的 DLL 鏈接到所生成的程序集中??梢钥闯?,在 test.exe 程序中,System.Numerics.BigInteger 是定義中 FSharp.Core 程序集中,而在 test2.exe 中,System.Numerics.BigInteger 被鏈接到生成的 test2 程序集中。

在 Windows 操作系統(tǒng)下編譯和運(yùn)行(使用面向 .NET Framework 4 的 F# 2.0 運(yùn)行時(shí)):

 
 
 
 
  1. E:\work> fsc.exe test.fs  
  2. Microsoft(R) F# 2.0 編譯器版本 4.0.30319.1  
  3. 版權(quán)所有(C) Microsoft Corporation。保留所有權(quán)利。  
  4.  
  5. E:\work> fsc.exe --out:test2.exe --standalone test.fs  
  6. Microsoft(R) F# 2.0 編譯器版本 4.0.30319.1  
  7. 版權(quán)所有(C) Microsoft Corporation。保留所有權(quán)利。  
  8.  
  9. E:\work> dir test*.exe  
  10.  驅(qū)動(dòng)器 E 中的卷是 Data2  
  11.  卷的序列號(hào)是 16BB-989E  
  12.  
  13.  E:\work 的目錄  
  14.  
  15. 2010/08/15  14:29             5,120 test.exe  
  16. 2010/08/15  14:30           880,128 test2.exe  
  17.                2 個(gè)文件        885,248 字節(jié)  
  18.                0 個(gè)目錄 51,641,475,072 可用字節(jié)  
  19.  
  20. E:\work> test.exe  
  21. OS  Version: Microsoft Windows NT 6.0.6002 Service Pack 2  
  22. CLR Version: 4.0.30319.1  
  23. System.Numerics.BigInteger, System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
  24.  
  25. E:\work> test2.exe  
  26. OS  Version: Microsoft Windows NT 6.0.6002 Service Pack 2  
  27. CLR Version: 4.0.30319.1  
  28. System.Numerics.BigInteger, System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
  29.  
  30. E:\work> 

可能看出,使用面向 .NET Framework 4 的 F# 2.0 運(yùn)行時(shí),System.Numerics.BigInteger 是 .NET Framework 4 的一部分,位于 System.Numerics 程序集中。不管是否使用  --standalone 參數(shù)編譯,都不會(huì)改變這一點(diǎn)。

此外,IronRuby 以及 IornPython 也分成面向 .NET Framework 2.0 和 .NET Framework 4 兩個(gè)版本。


網(wǎng)站標(biāo)題:詳解F#2.0中兩大運(yùn)行時(shí)的簡(jiǎn)單應(yīng)用
本文地址:http://www.dlmjj.cn/article/cdjggpe.html