Foundations of F#.Net phần 5

Tham khảo tài liệu 'foundations of f#.net phần 5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 116 CHAPTER 6 ORGANIZING ANNOTATING AND QUOTING CODE light module GColl let l new int Signature Files Signature files are a way of making function and value definitions private to a module. You ve already seen the syntax for the definition of a signature file in Chapter 2. It is the source that the compiler generates when using the -i switch. Any definitions that appear in a signature file are public and can be accessed by anyone using the module. Any that are not in the signature file are private and can be used only inside the module itself. The typical way to create a signature file is to generate it from the module source and then go through and erase any values and functions that you want to be private. The signature file name must be the same as the name of the module with which it is paired. It must have the extension .fsi or .mli. You must specify the signature file to the compiler. On the command line you must give it directly before the source file for its module. In Visual Studio the signature file must appear before the source file in Solution Explorer. For example if you have the following in the file light let funkyFunction x x keep it funky let notSoFunkyFunction x x 1 and you want to create a library that exposes funkyFunction but not notSoFunkyFunction you would use the signature code like this val funkyFunction string - string and would use the command line like this fsc -a which results in an assembly named with one class named Lib one public function named funkyFunction and one private function named notSoFunkyFunction. Module Scope The order that modules are passed to the compiler is important because it affects the scope of identifiers within the modules and the order in which the modules are executed. I cover scope in this section and execution order in the next. Values and types within a module cannot be seen from another module unless the module they re in appears on the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
272    23    1    30-11-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.