• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-341  評論-2670  文章-0  trackbacks-0
                新加入的Expected語法已經完全支持了。使用了Expected的符號會因為調用者的不同而使用不同的scope內的函數。代碼如下:

                首先,有main單元:
             1 module main
             2 import system
             3 import sysutils
             4 import list
             5 
             6 func eq T :: T -> T -> bool expected
             7 
             8 def exists e xs =
             9     select xs of
            10         case list x tail : if(eq e x) true (exists e tail)
            11         case empty : false
            12     end
            13 
            14 def eq a b = iequ a b
            15 def eq a b = fequ a b
            16 
            17 def main score = if (flt score 60.0"fail" "pass"
            18 
            19 def ints = list 1 (list 2 (list 3 empty))
            20 def floats = list 1.0 (list 2.0 (list 3.0 empty))
            21 def chars = "vczh"
            22 
            23 def main2 = exists 0 ints
            24 def main3 = exists 0.0 floats
                這里有一個eq的expected類型T->T->T->bool,然后還有兩個用于整數和實數的eq函數。

                其次,有main2單元:
            1 module main2
            2 import main
            3 
            4 def eq a b = iequ (ord a) (ord b)
            5 
            6 def main2 = exists 0 ints
            7 def main3 = exists 0.0 floats
            8 def main4 = exists 'a' chars
                這里有一個用于字符的eq函數。

                如果我們將def main4 = exists 'a' chars加入main模塊的話則會有錯誤:
            1 生成符號表時發生錯誤
            2 錯誤[1]    模塊:main    行號:10
            3 信息:符號"eq"無法匹配到函數,類型:(system.char -> (system.char -> system.bool))。

                因為這個時候eq存在于main2,main中的函數調用exists總是看到main中的內容。但是在main2就不同了,因為eq是expected的,main2調用的exists就可以看到main2的內容了。我們就可以看到期望的結果:
              1     module main::main
              2     import list
              3     import system
              4     import sysutils
              5     func eq T :: (<T> -> (<T> -> system.bool)) expected
              6     func chars :: (system.list system.char) codefrom 7
              7     func eq :: (system.int -> (system.int -> system.bool)) codefrom 2
              8     func eq :: (system.float -> (system.float -> system.bool)) codefrom 3
              9     func exists T1 :: (<T1> -> ((system.list <T1>-> system.bool)) codefrom 1 <Depends on expected functions>
             10     func floats :: (system.list system.float) codefrom 6
             11     func ints :: (system.list system.int) codefrom 5
             12     func main :: (system.float -> (system.list system.char)) codefrom 4
             13     func main2 :: system.bool codefrom 8
             14     func main3 :: system.bool codefrom 9
             15 
             16 【Code Unit main2】
             17     module main2::main2
             18     import main
             19     func eq :: (system.char -> (system.char -> system.bool)) codefrom 0
             20     func main2 :: system.bool codefrom 1
             21     func main3 :: system.bool codefrom 2
             22     func main4 :: system.bool codefrom 3
             23 
             24 【Assembly Unit main】
             25 
             26     [Information]
             27         Name             : main
             28         Function Count   : 10
             29         Slot Count       : 13
             30 
             31     [Function]
             32         Function Name    : exists
             33         Unique Name      : [callfrom:main2]main::exists::#1
             34         Owner Unit       : main
             35         Level            : 0
             36         External Command : 
             37         Instance         : <NULL>
             38 
             39     [Function]
             40         Function Name    : exists
             41         Unique Name      : [callfrom:main]main::exists::#1
             42         Owner Unit       : main
             43         Level            : 0
             44         External Command : 
             45         Instance         : <NULL>
             46 
             47     [Function]
             48         Function Name    : chars
             49         Unique Name      : main::chars::#7
             50         Owner Unit       : main
             51         Level            : 0
             52         External Command : 
             53         Instance         : main::chars::#7::(system.list system.char)
             54 
             55     [Function]
             56         Function Name    : eq
             57         Unique Name      : main::eq::#2
             58         Owner Unit       : main
             59         Level            : 0
             60         External Command : 
             61         Instance         : main::eq::#2::(system.int -> (system.int -> system.bool))
             62 
             63     [Function]
             64         Function Name    : eq
             65         Unique Name      : main::eq::#3
             66         Owner Unit       : main
             67         Level            : 0
             68         External Command : 
             69         Instance         : main::eq::#3::(system.float -> (system.float -> system.bool))
             70 
             71     [Function]
             72         Function Name    : floats
             73         Unique Name      : main::floats::#6
             74         Owner Unit       : main
             75         Level            : 0
             76         External Command : 
             77         Instance         : main::floats::#6::(system.list system.float)
             78 
             79     [Function]
             80         Function Name    : ints
             81         Unique Name      : main::ints::#5
             82         Owner Unit       : main
             83         Level            : 0
             84         External Command : 
             85         Instance         : main::ints::#5::(system.list system.int)
             86 
             87     [Function]
             88         Function Name    : main2
             89         Unique Name      : main::main2::#8
             90         Owner Unit       : main
             91         Level            : 0
             92         External Command : 
             93         Instance         : main::main2::#8::system.bool
             94 
             95     [Function]
             96         Function Name    : main3
             97         Unique Name      : main::main3::#9
             98         Owner Unit       : main
             99         Level            : 0
            100         External Command : 
            101         Instance         : main::main3::#9::system.bool
            102 
            103     [Function]
            104         Function Name    : main
            105         Unique Name      : main::main::#4
            106         Owner Unit       : main
            107         Level            : 0
            108         External Command : 
            109         Instance         : main::main::#4::(system.float -> (system.list system.char))
            110 
            111     [Slot Item]
            112         Unique Name      : [callfrom:main2]main::exists::#1::(system.char -> ((system.list system.char-> system.bool))
            113         Parent Slot      : <NULL>
            114         Owner Function   : [callfrom:main2]main::exists::#1
            115             0 = sysutils::if::#9::(system.bool -> (system.bool -> (system.bool -> system.bool)))
            116             1 = main2::eq::#0::(system.char -> (system.char -> system.bool))
            117             2 = [callfrom:main2]main::exists::#1::(system.char -> ((system.list system.char-> system.bool))
            118 
            119     [Slot Item]
            120         Unique Name      : [callfrom:main2]main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            121         Parent Slot      : <NULL>
            122         Owner Function   : [callfrom:main2]main::exists::#1
            123             0 = sysutils::if::#9::(system.bool -> (system.bool -> (system.bool -> system.bool)))
            124             1 = main::eq::#3::(system.float -> (system.float -> system.bool))
            125             2 = [callfrom:main2]main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            126 
            127     [Slot Item]
            128         Unique Name      : [callfrom:main2]main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            129         Parent Slot      : <NULL>
            130         Owner Function   : [callfrom:main2]main::exists::#1
            131             0 = sysutils::if::#9::(system.bool -> (system.bool -> (system.bool -> system.bool)))
            132             1 = main::eq::#2::(system.int -> (system.int -> system.bool))
            133             2 = [callfrom:main2]main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            134 
            135     [Slot Item]
            136         Unique Name      : [callfrom:main]main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            137         Parent Slot      : <NULL>
            138         Owner Function   : [callfrom:main]main::exists::#1
            139             0 = sysutils::if::#9::(system.bool -> (system.bool -> (system.bool -> system.bool)))
            140             1 = main::eq::#3::(system.float -> (system.float -> system.bool))
            141             2 = [callfrom:main]main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            142 
            143     [Slot Item]
            144         Unique Name      : [callfrom:main]main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            145         Parent Slot      : <NULL>
            146         Owner Function   : [callfrom:main]main::exists::#1
            147             0 = sysutils::if::#9::(system.bool -> (system.bool -> (system.bool -> system.bool)))
            148             1 = main::eq::#2::(system.int -> (system.int -> system.bool))
            149             2 = [callfrom:main]main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            150 
            151     [Slot Item]
            152         Unique Name      : main::chars::#7::(system.list system.char)
            153         Parent Slot      : <NULL>
            154         Owner Function   : main::chars::#7
            155 
            156     [Slot Item]
            157         Unique Name      : main::eq::#2::(system.int -> (system.int -> system.bool))
            158         Parent Slot      : <NULL>
            159         Owner Function   : main::eq::#2
            160             3 = system::iequ::$kernelfp::iequ::(system.int -> (system.int -> system.bool))
            161 
            162     [Slot Item]
            163         Unique Name      : main::eq::#3::(system.float -> (system.float -> system.bool))
            164         Parent Slot      : <NULL>
            165         Owner Function   : main::eq::#3
            166             4 = system::fequ::$kernelfp::fequ::(system.float -> (system.float -> system.bool))
            167 
            168     [Slot Item]
            169         Unique Name      : main::floats::#6::(system.list system.float)
            170         Parent Slot      : <NULL>
            171         Owner Function   : main::floats::#6
            172 
            173     [Slot Item]
            174         Unique Name      : main::ints::#5::(system.list system.int)
            175         Parent Slot      : <NULL>
            176         Owner Function   : main::ints::#5
            177 
            178     [Slot Item]
            179         Unique Name      : main::main2::#8::system.bool
            180         Parent Slot      : <NULL>
            181         Owner Function   : main::main2::#8
            182             7 = [callfrom:main]main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            183             8 = main::ints::#5::(system.list system.int)
            184 
            185     [Slot Item]
            186         Unique Name      : main::main3::#9::system.bool
            187         Parent Slot      : <NULL>
            188         Owner Function   : main::main3::#9
            189             9 = [callfrom:main]main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            190             10 = main::floats::#6::(system.list system.float)
            191 
            192     [Slot Item]
            193         Unique Name      : main::main::#4::(system.float -> (system.list system.char))
            194         Parent Slot      : <NULL>
            195         Owner Function   : main::main::#4
            196             5 = sysutils::if::#9::(system.bool -> ((system.list system.char-> ((system.list system.char-> (system.list system.char))))
            197             6 = system::flt::$kernelfp::flt::(system.float -> (system.float -> system.bool))
            198 
            199 【Assembly Unit main2】
            200 
            201     [Information]
            202         Name             : main2
            203         Function Count   : 4
            204         Slot Count       : 4
            205 
            206     [Function]
            207         Function Name    : eq
            208         Unique Name      : main2::eq::#0
            209         Owner Unit       : main2
            210         Level            : 0
            211         External Command : 
            212         Instance         : main2::eq::#0::(system.char -> (system.char -> system.bool))
            213 
            214     [Function]
            215         Function Name    : main2
            216         Unique Name      : main2::main2::#1
            217         Owner Unit       : main2
            218         Level            : 0
            219         External Command : 
            220         Instance         : main2::main2::#1::system.bool
            221 
            222     [Function]
            223         Function Name    : main3
            224         Unique Name      : main2::main3::#2
            225         Owner Unit       : main2
            226         Level            : 0
            227         External Command : 
            228         Instance         : main2::main3::#2::system.bool
            229 
            230     [Function]
            231         Function Name    : main4
            232         Unique Name      : main2::main4::#3
            233         Owner Unit       : main2
            234         Level            : 0
            235         External Command : 
            236         Instance         : main2::main4::#3::system.bool
            237 
            238     [Slot Item]
            239         Unique Name      : main2::eq::#0::(system.char -> (system.char -> system.bool))
            240         Parent Slot      : <NULL>
            241         Owner Function   : main2::eq::#0
            242             0 = system::iequ::$kernelfp::iequ::(system.int -> (system.int -> system.bool))
            243             1 = system::ord::$kernelfp::ord::(system.char -> system.int)
            244             2 = system::ord::$kernelfp::ord::(system.char -> system.int)
            245 
            246     [Slot Item]
            247         Unique Name      : main2::main2::#1::system.bool
            248         Parent Slot      : <NULL>
            249         Owner Function   : main2::main2::#1
            250             3 = [callfrom:main2]main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            251             4 = main::ints::#5::(system.list system.int)
            252 
            253     [Slot Item]
            254         Unique Name      : main2::main3::#2::system.bool
            255         Parent Slot      : <NULL>
            256         Owner Function   : main2::main3::#2
            257             5 = [callfrom:main2]main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            258             6 = main::floats::#6::(system.list system.float)
            259 
            260     [Slot Item]
            261         Unique Name      : main2::main4::#3::system.bool
            262         Parent Slot      : <NULL>
            263         Owner Function   : main2::main4::#3
            264             7 = [callfrom:main2]main::exists::#1::(system.char -> ((system.list system.char-> system.bool))
            265             8 = main::chars::#7::(system.list system.char)

                我們可以看到main模塊里面出現了兩個不同的exists函數:
             1     [Function]
             2         Function Name    : exists
             3         Unique Name      : [callfrom:main2]main::exists::#1
             4         Owner Unit       : main
             5         Level            : 0
             6         External Command : 
             7         Instance         : <NULL>
             8 
             9     [Function]
            10         Function Name    : exists
            11         Unique Name      : [callfrom:main]main::exists::#1
            12         Owner Unit       : main
            13         Level            : 0
            14         External Command : 
            15         Instance         : <NULL>
            posted on 2008-11-03 05:41 陳梓瀚(vczh) 閱讀(1673) 評論(0)  編輯 收藏 引用 所屬分類: 腳本技術
            91久久精品电影| 99久久99这里只有免费费精品| 99精品久久精品| 久久永久免费人妻精品下载| 狠狠色狠狠色综合久久| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 91久久香蕉国产熟女线看| 国产成人久久激情91| 好久久免费视频高清| 99久久婷婷国产一区二区| 狠狠色丁香婷婷综合久久来来去| 精品无码久久久久久国产| 狠狠人妻久久久久久综合| 综合久久一区二区三区| 久久久久久久久久久久久久| 久久久久久人妻无码| 国产高潮国产高潮久久久91 | 亚洲国产成人久久精品影视| 国产精品无码久久久久| 亚洲国产精品无码久久青草| 久久午夜夜伦鲁鲁片免费无码影视| 99精品国产99久久久久久97| 99999久久久久久亚洲| 99久久国产综合精品成人影院| 国产精品无码久久久久| 一本色综合网久久| 久久综合九色综合97_久久久| 亚洲国产精品成人久久蜜臀| 中文字幕无码免费久久| 久久久久久狠狠丁香| 久久久久久精品无码人妻| 国产精品99久久免费观看| 亚洲国产精品成人AV无码久久综合影院| 久久婷婷五月综合国产尤物app| 精品久久久久久久久午夜福利| 国产精品欧美久久久久天天影视| 精品久久久无码人妻中文字幕 | 色欲综合久久躁天天躁蜜桃 | 久久影院久久香蕉国产线看观看| 久久亚洲精品中文字幕| 伊人久久大香线蕉综合5g|