/interpreter/tags/at2dist130208/src/edu/vub/at/objects/ATTypeTag.java

http://ambienttalk.googlecode.com/ · Java · 85 lines · 8 code · 6 blank · 71 comment · 0 complexity · e84f3332b48eed10b91722ca97ee155e MD5 · raw file

  1. /**
  2. * AmbientTalk/2 Project
  3. * ATTypeTag.java created on 18-feb-2007 at 15:55:09
  4. * (c) Programming Technology Lab, 2006 - 2007
  5. * Authors: Tom Van Cutsem & Stijn Mostinckx
  6. *
  7. * Permission is hereby granted, free of charge, to any person
  8. * obtaining a copy of this software and associated documentation
  9. * files (the "Software"), to deal in the Software without
  10. * restriction, including without limitation the rights to use,
  11. * copy, modify, merge, publish, distribute, sublicense, and/or
  12. * sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following
  14. * conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. * OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28. package edu.vub.at.objects;
  29. import edu.vub.at.exceptions.InterpreterException;
  30. import edu.vub.at.objects.grammar.ATSymbol;
  31. /**
  32. * The public interface to a native type tag object.
  33. * <p>
  34. * Type tags consist of two properties:
  35. * <ul>
  36. * <li>they have a unique name by which they can be identified across the network.
  37. * In other words, the identity of a type is its name (= nominal typing).
  38. * <li>they have a list of supertypes: a type is then a subtype of these supertypes.
  39. * </ul>
  40. * <p>
  41. * Types have one important operation: one type can be tested to be a subtype of
  42. * another type.
  43. * <p>
  44. * Type tags are very similar to empty Java-like interface types, and their main purpose
  45. * lies in the *classification* of objects. AmbientTalk Objects can be tagged with zero
  46. * or more type tags.
  47. *
  48. * @author tvcutsem
  49. */
  50. public interface ATTypeTag extends ATObject {
  51. /**
  52. * Returns the name of this type tag.
  53. *
  54. * @return an {@link ATSymbol} representing the unique name by which the type can be identified.
  55. */
  56. public ATSymbol base_typeName() throws InterpreterException;
  57. /**
  58. * Returns a table with the supertypes of this type tag.
  59. *
  60. * @return an {@link ATTable} with the super types of the receiver type tags.
  61. */
  62. public ATTable base_superTypes() throws InterpreterException;
  63. /**
  64. * Returns true if this type tag is a subtype of a given type tag.
  65. * <p>
  66. * More specifically, what the native implementation (expressed in AmbientTalk syntax) does is:
  67. * <p>
  68. * <code>
  69. * def isSubtypeOf(supertype) {
  70. * (supertype.name() == name).or:
  71. * { (supertypes.find: { |stype| stype.isSubtypeOf(supertype) }) != nil }
  72. * };
  73. * </code>
  74. *
  75. * @param other a type.
  76. * @return true if the receiver type is a subtype of the other type.
  77. */
  78. public ATBoolean base_isSubtypeOf(ATTypeTag other) throws InterpreterException;
  79. }