螺旋幽门杆菌吃什么药治疗好| 什么时候征兵| 老子是什么时期的人| 蝙蝠怕什么| 老鼠跟什么属相最配| 惟妙惟肖是什么意思| 缺铁吃什么药| husky是什么牌子| 1958年属什么| 可怜巴巴是什么意思| 表水是什么意思| bbc是什么意思| 自闭症是什么| 女内分泌检查什么项目| 喉咙溃疡吃什么药| 寒热往来什么意思| 软组织肿胀是什么意思| 小便有血是什么原因| 三月三十号是什么星座| 无下限是什么意思| 四大才子是什么生肖| 尿气味重是什么原因| 桂圆不能和什么一起吃| 桥本甲状腺炎有什么症状| 胸前有痣代表什么意思| 睡觉中途总醒什么原因| 左后背疼什么原因| 摘胆对身体有什么影响| ny什么牌子| 初代是什么意思| 嘴巴长溃疡是什么原因| 睚眦欲裂什么意思| 屁股尾骨疼是什么原因| 湿疹有什么忌口的食物| 碳酸钙d3片什么时候吃最好| 人血馒头是什么意思| 女人男相有什么说法| 蛇生肖和什么生肖相配| 狗屎运是什么意思| 三庭五眼是什么意思| 什么品种的芒果最好吃| 三岁看小七岁看老是什么意思| 输卵管堵塞是什么原因| 眩晕症是什么| 养神经的药是什么药最好| 12月17日什么星座| 脑梗做什么检查最准确| 夏至吃什么食物| 小腿前面的骨头叫什么| 苛捐杂税是什么生肖| 机遇什么意思| 下半夜咳嗽是什么原因| 脑挫伤是什么意思| 5月5日什么星座| 什么变什么化| 感冒了吃什么| 蜂蜜不能和什么食物一起吃| 轻度抑郁症吃什么药| 胸腔积液是什么意思| 12月是什么星座的| 锁骨上有痣代表什么| 精是什么意思| 排卵试纸一深一浅说明什么| 小孩晚上睡觉磨牙是什么原因| 早泄吃什么好| 洋气是什么意思| 有什么好吃的| ab型和ab型生的孩子是什么血型| 什么的假山| 常务副县长什么级别| 梦到杀人是什么意思| 伤官什么意思| 蝙蝠是什么变的| 怀孕之后身体有什么变化| 煮牛肉放什么调料| 妈妈a型爸爸b型孩子是什么血型| 越睡越困是什么原因| 月亮发红是什么原因| 小孩打嗝是什么原因| 雪碧喝多了有什么危害| 子宫内膜息肉有什么症状| 1981年属鸡是什么命| 血管硬化吃什么能软化| 子宁不嗣音什么意思| 喉炎吃什么药效果最好| 牙齿发黑是什么原因| 牙龈萎缩用什么牙膏好| 五粮液是什么香型的酒| 狗为什么喜欢吃屎| 智齿前面一颗牙叫什么| 西字里面加一横是什么字| 子宫腺肌症有什么症状| 暴跳如雷是什么意思| 牛子是什么意思| 拉肚子是什么原因导致的| 什么叫湿热| 莅临什么意思| 肚子经常疼是什么原因| futa是什么意思| 降血糖的草都有什么草| 三代试管是什么意思| 梦到钓鱼是什么征兆| 大陆人去香港需要什么证件| 侏儒是什么意思| 自愈什么意思| 女生安全期是什么意思| 人脉是什么意思| 1964年是什么生肖| 抗核抗体阴性说明什么| coach是什么牌子的包| 斋醮什么意思| 朱砂有什么功效| 什么是两栖动物| 9-11点是什么时辰| 为什么乳头会变黑| 看输卵管是否堵塞做什么检查| 罗衣是什么意思| inr是什么意思| 什么情况打破伤风| 菠菜什么时候传入中国| 3月31号什么星座| 火车动车高铁有什么区别| 腰间盘突出吃什么药| 粗糙的什么| 1977年是什么命| 草鱼喜欢吃什么| 岑字五行属什么| 什么水果糖分最高| 头皮痒用什么洗头好| 肋骨外翻有什么危害| 雅诗兰黛是什么档次| 孕妇吃鸽子蛋对胎儿有什么好处| 什么情况属于诈骗| 白细胞满视野是什么意思| 什么是眼底病| 杞子配什么增强性功能| 馐什么意思| 头发的主要成分是什么| 负离子有什么作用| 梦见栽树是什么预兆| 血糖有点高吃什么食物好| 急诊是什么意思| 空姐在飞机上干什么| 什么动物是站着睡觉的| 5月26号什么星座| asic是什么意思| 秋千为什么叫秋千| 五行中什么生水| 他达拉非是什么药| 难为情是什么意思| 异地办理临时身份证需要什么材料| 吃什么补钾最快最好| 空调出风小没劲什么原因| 吃东西就打嗝是什么原因| 小便有点刺痛是什么原因引起的| 吃什么对胰腺好| 焕字五行属什么| 冬天怕冷夏天怕热是什么体质| 怀孕两个月有什么症状| 海蜇是什么| 冬天怕冷夏天怕热是什么体质| 量词是什么意思| 凌晨一点半是什么时辰| 眼镜发黄是什么原因| 宝宝睡觉头上出汗多是什么原因| 虚火是什么意思| 兰花是什么季节开的| 吃猪腰子有什么好处和坏处| 肝内脂质沉积是什么意思| 脚痒用什么药膏最有效| 履什么意思| 江西什么最出名| 澳大利亚属于什么洲| 大明湖畔的夏雨荷是什么意思| pvd是什么材料| 头皮屑多用什么洗发水效果好| 一抽一抽的打嗝叫什么| 筠字五行属什么| 晚上七点到九点是什么时辰| 刘封为什么不救关羽| 吃什么能瘦| 脑白质缺血性改变什么意思| 黑加仑是什么| 什么是偏光镜| 什么的森林| 白垩纪是什么意思| 鼻头发红是什么原因| 孩子发烧呕吐是什么原因| 小孩肚脐眼上面疼是什么原因| 腰椎生理曲度变直是什么意思| 为什么眼皮会一直跳| 男性支原体阳性有什么症状| 老树盘根是什么意思| 友尽是什么意思| 甲亢是什么原因导致的| 什么情况下要打破伤风| 梵文是什么意思| 蛇头是什么意思| 小肠镜什么情况下需要做| 羊肉和什么一起炖最好| 米黄配什么颜色好看| 女人跑马是什么意思| 在农村做什么生意好| 直肠炎是什么原因引起的| 中性粒细胞百分比低是什么原因| 改嫁是什么意思| 贫血吃什么药| 落红是什么意思| 一什么云| 心态崩了什么意思| 59岁生日有什么讲究| 借什么可以不还| 桂圆什么时候成熟| 遗忘的遗是什么意思| 为什么总想睡觉| 吃什么可以通便| 执行标准是什么意思| 大肠杆菌属于什么菌| 千斤拔泡酒有什么功效| 半梦半醒是什么意思| essence什么意思| ha是什么意思| 花椒吃多了对身体有什么影响| 肩周炎不能吃什么食物| 三七草长什么样| 人为什么要日b| 真皮是什么皮| 酱油是什么做的| 吃桑葚有什么好处| 暗里着迷什么意思| 庚日是什么意思| 尿黄是什么原因引起的男性| 申酉是什么时间| 药剂师是做什么的| 羊驼为什么吐口水| Urea医学上是什么意思| 不眠之夜是什么意思| 蜡笔小新的爸爸叫什么| 吃了龙虾后不能吃什么| 如日中天是什么生肖| 学杂费包括什么| 戴芬是什么药| 早餐吃什么不升血糖| 口苦口干吃什么药好| 唐氏筛查是检查什么| 一什么桌子| 女人吃什么对卵巢和子宫好| 溺爱什么意思| 不什么不| 心肾不交是什么意思| 71年属猪是什么命| 女性适合喝什么茶| 结扎挂什么科| 黄瓜长什么样| 双鱼和什么星座最配| 谷朊粉是什么| 耳朵里面疼用什么药| 红曲是什么东西| 2001年属什么生肖| 肽对人体有什么好处| 神经过敏是什么意思| 小孩呕吐是什么原因引起的| 下半年有什么节日| 结肠炎吃什么药| 百度Jump to content

《异域镇魂曲:增强版》LMAO 1.5内核汉化补丁发布

From Wikipedia, the free encyclopedia
百度 KeepK1搭载了一颗定制化的OLED显示屏旋钮,集合了跑步机所有的操作功能。

The expression problem is a challenging problem in programming languages that concerns the extensibility and modularity of statically typed data abstractions. The goal is to define a data abstraction that is extensible both in its representations and its behaviors, where one can add new representations and new behaviors to the data abstraction, without recompiling existing code, and while retaining static type safety (e.g., no casts). The statement of the problem exposes deficiencies in programming paradigms and programming languages. Philip Wadler, one of the co-authors of Haskell, has originated the term.

History

[edit]

Philip Wadler formulated the challenge and named it "The Expression Problem"[1] in response to a discussion with Rice University's Programming Languages Team (PLT). He also cited three sources that defined the context for his challenge:

The problem was first observed by John Reynolds in 1975.[2] Reynolds discussed two forms of Data Abstraction: User-defined Types, which are now known as Abstract Data Types (ADTs) (not to be confused with Algebraic Data Types), and Procedural Data Structures, which are now understood as a primitive form of Objects with only one method. He argued that they are complementary, in that User-defined Types could be extended with new behaviors, and Procedural Data Structures could be extended with new representations. He also discussed related work going back to 1967. Fifteen years later in 1990, William Cook[3] applied Reynold's idea in the context of Objects and Abstract Data Types, which had both grown extensively. Cook identified the matrix of representations and behaviors that are implicit in a Data Abstraction, and discussed how ADTs are based on the behavioral axis, while Objects are based on the representation axis. He provides extensive discussion of work on ADTs and Objects that are relevant to the problem. He also reviewed implementations in both styles, discussed extensibility in both directions, and also identified the importance of static typing. Most importantly, he discussed situations in which there was more flexibility than Reynolds considered, including internalization and optimization of methods.

At ECOOP '98, Shriram Krishnamurthi et al.[4] presented a design pattern solution to the problem of simultaneously extending an expression-oriented programming language and its tool-set. They dubbed it the "expressivity problem" because they thought programming language designers could use the problem to demonstrate the expressive power of their creations. For PLT, the problem had shown up in the construction of DrScheme, now DrRacket, and they solved it[5] via a rediscovery of mixins.[6][7] To avoid using a programming language problem in a paper about programming languages, Krishnamurthi et al. used an old geometry programming problem to explain their pattern-oriented solution. In conversations with Felleisen and Krishnamurthi after the ECOOP presentation, Wadler understood the PL-centric nature of the problem and he pointed out that Krishnamurthi's solution used a cast to circumvent Java's type system. The discussion continued on the types mailing list, where Corky Cartwright (Rice) and Kim Bruce (Williams) showed how type systems for OO languages might eliminate this cast. In response Wadler formulated his essay and stated the challenge, "whether a language can solve the expression problem is a salient indicator of its capacity for expression." The label "expression problem" puns on expression = "how much can your language express" and expression = "the terms you are trying to represent are language expressions".

Others co-discovered variants of the expression problem around the same time as Rice University's PLT, in particular Thomas Kühne[8] in his dissertation, and Smaragdakis and Batory[9] in a parallel ECOOP 98 article.

Some follow-up work used the expression problem to showcase the power of programming language designs.[10][11]

The expression problem is also a fundamental problem in multi-dimensional Software Product Line design and in particular as an application or special case of FOSD Program Cubes.[citation needed]

Solutions

[edit]

There are various solutions to the expression problem. Each solution varies in the amount of code a user must write to implement them, and the language features they require.

Example

[edit]

Problem description

[edit]

We can imagine we do not have the source code for the following library, written in C#, which we wish to extend:

interface IEvalExp
{
    int Eval();
}

class Lit : IEvalExp
{
    internal Lit(int n)
    {
        N = n;
    }

    internal int N { get; }

    public int Eval()
    {
        return N;
    }
}

class Add : IEvalExp
{
    internal Add(IEvalExp left, IEvalExp right)
    {
        Left = left;
        Right = right;
    }

    internal IEvalExp Left { get; }

    internal IEvalExp Right { get; }

    public int Eval()
    {
        return Left.Eval() + Right.Eval();
    }
}

static class ExampleOne
{
    static IEvalExp AddOneAndTwo() => new Add(new Lit(1), new Lit(2));
    static int EvaluateTheSumOfOneAndTwo() => AddOneAndTwo().Eval();
}

Using this library we can express the arithmetic expression 1 + 2 as we did in ExampleOne.AddOneAndTwo() and can evaluate the expression by calling .Eval(). Now imagine that we wish to extend this library, adding a new type is easy because we are working with an Object-oriented programming language. For example, we might create the following class:

class Mult : IEvalExp
{
    internal Mult(IEvalExp left, IEvalExp right)
    {
        Left = left;
        Right = right;
    }

    internal IEvalExp Left { get; }

    internal IEvalExp Right { get; }

    public int Eval()
    {
        return Left.Eval() * Right.Eval();
    }
}

However, if we wish to add a new function over the type (a new method in C# terminology), for example to pretty print an expression, we have to change the IEvalExp interface and then modify all the classes that implement the interface. Another possibility is to create a new interface that extends the IEvalExp interface and then create sub-types for Lit, Add and Mult classes, but the expression returned in ExampleOne.AddOneAndTwo() has already been compiled so we will not be able to use the new function over the old type. The problem is reversed in functional programming languages like F# where it is easy to add a function over a given type, but extending or adding types is difficult.

Problem solution using object algebra

[edit]

Let us redesign the original library with extensibility in mind using the ideas from the paper Extensibility for the Masses.[17]

interface ExpAlgebra<T>
{
    T Lit(int n);
    T Add(T left, T right);
}

class ExpFactory : ExpAlgebra<IEvalExp>
{
    public IEvalExp Lit(int n)
    {
        return new Lit(n);
    }

    public IEvalExp Add(IEvalExp left, IEvalExp right)
    {
        return new Add(left, right);
    }
}

static class ExampleTwo<T>
{
    public static T AddOneToTwo(ExpAlgebra<T> ae) => ae.Add(ae.Lit(1), ae.Lit(2));
}

We use the same implementation as in the first code example but now add a new interface containing the functions over the type as well as a factory for the algebra. Notice that we now generate the expression in ExampleTwo.AddOneToTwo() using the ExpAlgebra<T> interface instead of directly from the types. We can now add a function by extending the ExpAlgebra<T> interface, we will add functionality to print the expression:

interface IPrintExp : IEvalExp
{
    string Print();
}

class PrintableLit : Lit, IPrintExp
{
    internal PrintableLit(int n) : base(n)
    {
        N = n;
    }

    internal int N { get; }

    public string Print()
    {
        return N.ToString();
    }
}

class PrintableAdd : Add, IPrintExp
{
    internal PrintableAdd(IPrintExp left, IPrintExp right) : base(left, right)
    {
        Left = left;
        Right = right;
    }

    internal new IPrintExp Left { get; }

    internal new IPrintExp Right { get; }

    public string Print()
    {
        return Left.Print() + " + " + Right.Print();
    }
}

class PrintFactory : ExpFactory, ExpAlgebra<IPrintExp>
{
    public IPrintExp Add(IPrintExp left, IPrintExp right)
    {
        return new PrintableAdd(left, right);
    }

    public new IPrintExp Lit(int n)
    {
        return new PrintableLit(n);
    }
}

static class ExampleThree
{
    internal static int Evaluate() => ExampleTwo<IPrintExp>.AddOneToTwo(new PrintFactory()).Eval();
    internal static string Print() => ExampleTwo<IPrintExp>.AddOneToTwo(new PrintFactory()).Print();
}

Notice that in ExampleThree.Print() we are printing an expression that was already compiled in ExampleTwo, we did not need to modify any existing code. Notice also that this is still strongly typed, we do not need reflection or casting. If we would replace the PrintFactory() with the ExpFactory() in the ExampleThree.Print() we would get a compilation error since the .Print() method does not exist in that context.

See also

[edit]

References

[edit]
  1. ^ "The Expression Problem".
  2. ^ Reynolds, John C. (1975). "User-defined Types and Procedural Data Structures as complementary approaches to Data Abstraction.". New Directions in Algorithmic Languages (PDF). IFIP Working Group 2.1 on Algol. pp. 157–168.
  3. ^ Cook, William (1990). "Object-Oriented Programming versus Abstract Data Types". In Bakker, J.W. de; Roever, W.P. de; Rozenberg, G. (eds.). Foundations of Object-Oriented Languages (FOOL), REX School/Workshop. Lecture Notes in Computer Science. Vol. 489. Noordwijkerhout, The Netherlands: Springer Berlin Heidelberg. pp. 151–178. doi:10.1007/BFb0019443. ISBN 978-3-540-46450-1.
  4. ^ "Synthesizing Object-Oriented and Functional Design to Promote Re-Use".
  5. ^ Findler, Robert Bruce; Flatt, Matthew (1999). "Modular object-oriented programming with units and mixins". ACM SIGPLAN Notices. 34: 94–104. doi:10.1145/291251.289432.
  6. ^ Cook, William (1989). A Denotational Semantics of Inheritance (PDF) (PhD). Brown University.
  7. ^ Flatt, Matthew; Krishnamurthi, Shriram; Felleisen, Matthias (1998). "Classes and Mixins". Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '98. pp. 171–183. doi:10.1145/268946.268961. ISBN 978-0897919791. S2CID 5815257.
  8. ^ Kühne, Thomas (1999). A Functional Pattern System for Object-Oriented Design. Darmstadt: Verlag Dr. Kovac. ISBN 978-3-86064-770-7.
  9. ^ Smaragdakis, Yannis; Don Batory (1998). Implementing Reusable Object-Oriented Components. Lecture Notes in Computer Science. Vol. 1445.
  10. ^ Zenger, Matthias; Odersky, Martin (2001). "Extensible Algebraic Datatypes with Defaults". Proceedings of the sixth ACM SIGPLAN international conference on Functional programming. pp. 241–252. CiteSeerX 10.1.1.28.6778. doi:10.1145/507635.507665. ISBN 1-58113-415-0.
  11. ^ Zenger, Matthias; Odersky, Martin (2005). "Independently extensible solutions to the expression problem" (PDF). FOOL 2005. ACM. CiteSeerX 10.1.1.107.4449.
  12. ^ Chambers, Craig; Leavens, Gary T. (November 1995). "Type Checking and Modules for Multi-Methods". ACM Transactions on Programming Languages and Systems. 17 (6): 805–843. doi:10.1145/218570.218571.
  13. ^ Clifton, Curtis; Leavens, Gary T.; Chambers, Craig; Millstein, Todd (2000). "MultiJava: Modular open classes and symmetric multiple dispatch for Java". Proceedings of the 15th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications (PDF). pp. 130–145. doi:10.1145/353171.353181. ISBN 978-1-58113-200-7. S2CID 7879645.
  14. ^ Wouter Swierstra (2008). "Data Types à La Carte". Journal of Functional Programming. 18 (4). Cambridge University Press: 423–436. doi:10.1017/S0956796808006758. ISSN 0956-7968. S2CID 21038598.
  15. ^ Wehr, Stefan; Thiemann, Peter (July 2011). "JavaGI: The Interaction of Type Classes with Interfaces and Inheritance". ACM Transactions on Programming Languages and Systems. 33 (4): 1–83. doi:10.1145/1985342.1985343. S2CID 13174506.
  16. ^ Carette, Jacques; Kiselyov, Oleg; Chung-chieh, Shan (2009). "Finally Tagless, Partially Evaluated: Tagless Staged Interpreters for Simpler Typed Languages" (PDF). J. Funct. Program. 19 (5): 509–543. doi:10.1017/S0956796809007205. S2CID 6054319.
  17. ^ a b Oliveira, Bruno C. d. S.; Cook, William R. (2012). "Extensibility for the Masses: Practical Extensibility with Object Algebras" (PDF). Ecoop '12.
  18. ^ Garrigue, Jacques (2000). "Code Reuse Through Polymorphic Variants" (PDF). Workshop on Foundations of Software Engineering. Sasaguri, Japan, November 2000. CiteSeerX 10.1.1.128.7169.
[edit]
狗男和什么属相最配 小三阳吃什么药 5月17日是什么星座 i.t品牌什么档次 生孩子前要注意什么
发烧喝什么饮料比较好 dunk是什么意思 半元音是什么意思 pvs是什么意思 腿麻是什么病的前兆吗
脊柱侧弯挂什么科 甲状腺减退什么症状 男人阳气不足有什么症状 植物神经紊乱吃什么药 尿胆原高是什么原因
肌层回声欠均匀是什么意思 女生下面是什么样的 白蚁吃什么 91年的羊是什么命 蚂蚁属于什么动物
lf是什么意思hcv9jop0ns9r.cn 开斋节是什么意思hcv9jop0ns0r.cn 一个家庭最重要的是什么wmyky.com 20至30元什么烟最好抽hcv9jop1ns9r.cn 猪横利是什么creativexi.com
诱因是什么意思hcv8jop8ns2r.cn 花胶是什么鱼的鱼肚hcv9jop2ns7r.cn 寒窗是什么意思hcv9jop2ns0r.cn 高血脂挂什么科hcv8jop9ns1r.cn 吃brunch是什么意思啊hcv7jop5ns6r.cn
生蚝有什么功效与作用wuhaiwuya.com pouch什么意思hcv8jop9ns2r.cn 绝代双骄是什么意思hcv9jop7ns3r.cn 专科和本科有什么区别hcv9jop4ns6r.cn 对立面是什么意思hcv9jop6ns0r.cn
5月8号是什么日子beikeqingting.com 生理期什么意思xinjiangjialails.com 复出是什么意思hcv8jop5ns9r.cn 肺囊肿是什么病严重吗1949doufunao.com 总蛋白是什么hcv8jop0ns6r.cn
百度