Java ã®ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãã¨ããæ©è½ã®å ãã¿
å
·ä½çãªè¨èªå¦çç³»ã¨ããããã§ã¯ããã¾ãããããããããããå
ãã¿ã ããã¨ããã¢ã¤ãã¢ãè¨ãããè«æã¯è¦ã¤ããã¾ããããã£ã¨ãã´ã¹ãªã³ã°ã Java ã Oakï¼Java ã®å身â¦ã¨ãããåæãã¼ã¸ã§ã³ãã®ãã®ãå¤ãã£ãã®ã¯ååã ããªã®ã§ï¼ã«ã¤ãã¦æ¸ãããã®ã« Java ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯ââãåèã«ãã¦èããâ¦ã¨ããè¨è¿°ãè¦ã¤ããããã«ããã®ã§ããããFAã¨ããã«ã¯ãããå°ã調æ»ãå¿
è¦ããã§ãããã¨ããããã¨ãããã¨ã§ã
ãã®è«æä¸ã§ã¯ããã¨ãã° Point ã¨ããã¤ã³ã¿ã¼ãã§ã¤ã¹ãå®ç¾©ãã¦ããããå®è£
ãã polar_point ã¨ããã¯ã©ã¹ãå®ç¾©ããä¾ã¨ãã¦ãä»®æ³è¨èªãç¨ãã¦ãããªã³ã¼ãã示ããã¦ãã¾ãã
interface Point x() returns Real y() returns Real move(Rea1, Real) returns Point equal(Point) returns Boolean
class polar_point(x:Real, y:Real) implements Point variable rho:Real := sqrt((x*x)+(y*y)) variable theta:Real := arctangent(y/x) method x() returns Real return rho * sinettheta) method y() returns Real return rho * cosine(theta) method move(dx:Real, dy:Real) returns Point return new myclass(self.x()+dx, self.y()+dy) method equal(p:Point) returns Boolean return (self.x() = p.x()) and (self.y() = p.y())
ã¯ã©ã¹ã«å¯¾ããã¤ã³ã¿ã¼ãã§ã¤ã¹ã®å®è£
ã®å®£è¨ã« implements ã使ã£ã¦ãããããã« Java ã¸ã®å½±é¿ã®çé±ãè¦ãããã¨æãã®ã¯ããã¡ããã§ãããããããã¯æå㪠Inheritance Is Not Subtyping (1990) [PDF] ã®å
ã«ãªã£ãè«æã¿ãããªã®ã§ã使ããã¦ãããµã³ãã«ã³ã¼ãã主張ã¯ä¸¡è
ã§ããä¼¼ã¦ãã¾ããããã§èªã¿ããã¨ãã人ã¯ãã¡ããã©ããï¼ãã ãã®ã£ãããå¼ãåºã¦ãããã§ãå¹³æ㪠Interfaces for... ããå°ã
é£è§£ã§ããã注æããããï¼ã
ã¨ããã§ãç§ã®ãã㪠Smalltalk ãã¡ã³ã«ã¯ããã¸ãèå³æ·±ããã¨ã«ãã©ããããã®ã¯ãã¯ãã®ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãã®ããã«å
ãã¿ã®ã¨ããã§ããªã㨠Smalltalk ãä¸æããã§ãããããã®ã§ããã¨è¨ãã¨ãåçåä»ãã®æ¨©åã®ãã㪠Smalltalk ã§ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãï¼ã¨ãã¶ãããã人ãå¤ãã§ããããããã¡ããå½æã® Smalltalk-80 ãã®ãã®ãã°ãã§ã¯ãªããããã«éçåãã§ãã¯ãå°å
¥ãã 1982 å¹´ã®å®é¨çãªå®è£
ã«ã¤ãã¦ã§ãããã㯠Smalltalk ã®ä¸ã®äººã§ããã¤ã³ã¬ã«ã¹ã¨ ThingLabï¼ã¤ã³ã¹ã¿ã³ã¹ãã¼ã¹ãªè¨èªã§æå㪠SELF ã®å
ãã¿ã«ãªã£ãã½ããã¦ã¨ã¢ï¼ã®ä¸ã®äººã§ãããã¼ãã³ã°ã«ããä»äºã§ãã
追è¨ï¼ããã§ãã¨ããã«ãä¸ã®äººãã強調ããã¨èª¤è§£ãããã¨ãããªããªã¨ãã¨ã§æ°ã¥ããã®ã§å¿µã®ããæ¸ãã¾ãããSmalltalk ã¯é常ã®è¨èªå¦çç³»ã§ã®å¸¸èã¨ã¯éããã¨ã³ãã¦ã¼ã¶ã¼ã¬ãã«ã§è¨èªä»æ§ãå¤æ´ã§ããã¡ãã£ã¨ï¼ããããªãâ¦ï¼å¤ãã£ãæ§æ ¼ãæããå¦çç³»ãªã®ã§ãããããæ¡å¼µãããã®ã«ãããããä¸ã®äººãã§ããå¿
è¦ã¯ã¾ã£ããããã¾ãããå
·ä½çã«ã©ããªãµãã«ãããã§ããã®ãã«ã¤ãã¦ã¯ï¼ã¡ãã£ã¨å¤ããã¼ã¸ã§ã³åãã§ã¯ããã¾ããï¼Squeak Smalltalk ã«ãããããã¤ã³ã¿ã¼ãã§ã¤ã¹ãã®ãã®ãã°ãã追å ãã話ã umejava ãããæ¸ãã¦ãã ãã£ã¦ããï¼Happy Squeaking!! -オブジェクト指向再入門- 第四回:メタ機能との出会いï¼ã®ã§ããã¡ãããã²åèã«ãªãã£ã¦ãã ãããSqueak2.2 㯠本家アーカイブ ãªã©ããå
¥æã§ãã¾ãã
Interfaces for... ã®æ¢å¾ç 究ã®ã»ã¯ã·ã§ã³ã«ããã® Smalltalk ã®ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãã«ã¤ãã¦ã®è¨åãããã¾ãã®ã§æç²ãã¦å¼ç¨ãã¾ãã
Interfaces for strongly-typed object-oriented programming - 5. Related Work
There have been several attempts to introduce interfaces into object-oriented programming. Efforts within the object-oriented language community include the work of Borning and Ingalls [BI82], the Emerald group [BHJ87], and Johnson et al. [JGZ88], all of whom have a notion of interface as message protocol. [BI82] and [JGZ88] describe type systems for Smalltalk with types based both on classes and protocols. The [BI82] work is less formal and does not distinguish interface containment from inheritance; nevertheless, it captures much of the essential structure of object interfaces. The more recent [JGZ88] work is interesting for its mixing of class-based and interface types, and has a limited form of polymorphism as found in ML. Emerald introduces interfaces to provide uniformity in a distributed object system. However, the interface system supports only limited parametric polymorphism and there is no notion of inheritance. Similarly, Modula-3 [CDK89] has notions of object and interface, but without polymorphism.
In most typed object-oriented languages, including Simula, C++, and Eiffel, the notion of type is different from ours. In those languages, classes are types, so that a type gives information about how objects are implemented. This improves performance and also provides the benefits of static type-checking, but at a cost in flexibility, which is significant for system development. In addition to collapsing the distinction between interface and implementation, the notions of interface containment and inheritance are confused[Coo89]. The result is that programs that would be correct in Smalltalk cannot be type-checked in these languages.
[BI82] A. H. Borning and D. H. Ingalls. "A type declaration and inference system for Smalltalk". In ACM Symposium on Principles of Programming Languages, 1982.
[BHJ87] A. Black, N. Hutchinson, E. Jul, H. Levy, and L. Carter. "Distribution and abstract types in Emerald". IEEE Transactions on Software Engineering, SE-13(l), 1987
[JGZ88] R. Johnson, J. Graver, and L. Zurawski. "TS: An optimizing compiler for SmalltaW. In Object-Oriented Programming Systems, Languages, and Applications, 1988.
[CDK89] L. Cardelli, J. Donahue, B. Kaslow, and G. Nelson. "The Modula-3 type system". In ACM Symposium on Principles of Programming Languages, 1989.
[Coo89] W. R. Cook. "A proposal for making Eiffel type-safe". In European Conference on Object-oriented Programming, 1989.
ã¤ã¾ãã¨ãããã¤ã³ã¬ã«ã¹ãã¡ã® Smalltalk ã«ããããã¤ã³ã¿ã¼ãã§ã¤ã¹ãï¼ã¡ãªã¿ã«å½¼ãã¯ããããã³ã«ãã¨å¼ãã ããããã Objective-C ã®ããããã³ã«ãã¨ããå¼ã³åã¯ããããã§ãããï¼ã¯ãã¯ã£ããã¨ã¯ã©ã¹ç¶æ¿ãããã¤ã³ã¿ã¼ãã§ã¤ã¹ããåé¢ãããã¨ãããã®ã§ã¯ãªãã£ãããã©ããã£ãã¨ããã¨ã³ãã£ãã£ã¨ãã¦åå¨ãï¼ã¾ããSmalltalk ã§ã®å®è£
ã§ãããå½ç¶ãããªãã¾ãããªâ¦(^_^;)ï¼ããã¤ã³ã¿ã¼ãã§ã¤ã¹ããæã¤ã¹ãç´ é¤ã¯ãã§ã«åãã¦ãããã¨ãã£ããããªãã¨ã®ããã§ãã
åæã«æç²ã®å¾åã§ã¯ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãå®è£ ã¨åãã¦èãããã¨èªä½ã¯éçåè¨èªã§æ¯è¼ç以åãããªããã¦ããããã©ãã¯ã©ã¹ã®ãããªã¨ã³ãã£ãã£ã¨ãã¦ã®ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãããã®ç¶æ¿ã¢ãã«ã¾ã§è¨åãããããææ¡ããã®ã¯ãã®è«æãåãã¦ã ã¨ãã主張ãï¼æç²ã®ååã¨ä½µãã¦ï¼ãªããã¦ããããã«ã¨ãã¾ããã
æãè¦ã¦ãJava å´ããã調æ»ã§ããã°ãã¨æã£ã¦ãã¾ãã