• <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精品国产综合久久香蕉| 色综合久久久久综合体桃花网| 久久午夜免费视频| 2020最新久久久视精品爱| 麻豆AV一区二区三区久久| 久久久久久久波多野结衣高潮| 久久久久婷婷| 精品久久久久中文字| 爱做久久久久久| 久久免费视频网站| 久久综合综合久久狠狠狠97色88| 99999久久久久久亚洲| 久久精品a亚洲国产v高清不卡| 日韩精品久久久久久久电影蜜臀| 亚洲午夜久久久久久久久久| 久久综合亚洲色一区二区三区| 久久久国产视频| 97久久国产露脸精品国产| 久久AV高潮AV无码AV| 亚洲国产精品无码久久久秋霞2| 97精品国产97久久久久久免费| 亚洲乱码中文字幕久久孕妇黑人| 日韩久久久久久中文人妻| 99精品久久久久中文字幕| 久久精品嫩草影院| 久久免费视频6| 久久人妻无码中文字幕| 日产精品久久久久久久性色| 国产情侣久久久久aⅴ免费| 免费国产99久久久香蕉| 久久亚洲视频| 一本色道久久综合亚洲精品| 国产V综合V亚洲欧美久久| 国产精品成人久久久久三级午夜电影 | 久久久久久亚洲Av无码精品专口| 亚洲精品tv久久久久久久久| 久久狠狠高潮亚洲精品| 国产福利电影一区二区三区久久老子无码午夜伦不 | 91精品国产综合久久四虎久久无码一级 | 精品人妻伦九区久久AAA片69| 久久久这里只有精品加勒比|