Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Modula-3
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Revelation === Modula-3's <code>REVEAL</code> construct provides a conceptually simple and clean yet very powerful mechanism for hiding implementation details from clients, with arbitrarily many levels of ''friendliness''. A full revelation of the form <code>REVEAL T = V</code> can be used to show the full implementation of the <code>Person</code> interface from above. A partial revelation of the form <code>REVEAL T <: V</code> merely reveals that T is a supertype of V without revealing any additional information on T.<ref>{{Cite journal |last1=Cardelli |first1=Luca |last2=Donahue |first2=James |last3=Glassman |first3=Lucille |last4=Jordan |first4=Mick |last5=Kalsow |first5=Bill |last6=Nelson |first6=Greg |date=August 1992 |title=Modula-3 language definition |url=https://dl.acm.org/doi/10.1145/142137.142141 |journal=ACM SIGPLAN Notices |language=en |volume=27 |issue=8 |pages=15β42 |doi=10.1145/142137.142141 |issn=0362-1340}}</ref> <syntaxhighlight lang="modula2"> MODULE Person; REVEAL T = Public BRANDED OBJECT name: TEXT; (* These two variables *) age: INTEGER; (* are private. *) OVERRIDES getAge := Age; init := Init; END; PROCEDURE Age(self: T): INTEGER = BEGIN RETURN self.age; END Age; PROCEDURE Init(self: T; name: TEXT; age: INTEGER): T = BEGIN self.name := name; self.age := age; RETURN self; END Init; BEGIN END Person. </syntaxhighlight> Note the use of the <code>BRANDED</code> keyword, which "brands" objects to make them unique as to avoid structural equivalence. <code>BRANDED</code> can also take a string as an argument, but when omitted, a unique string is generated for you. Modula-3 is one of a few programming languages which requires external references from a module to be strictly qualified. That is, a reference in module <code>A</code> to the object <code>x</code> exported from module <code>B</code> must take the form <code>B.x</code>. In Modula-3, it is impossible to import ''all exported names'' from a module. Because of the language's requirements on name qualification and [[method overriding]], it is impossible to break a working program simply by adding new declarations to an interface (any interface). This makes it possible for large programs to be edited concurrently by many programmers with no worries about naming conflicts; and it also makes it possible to edit core language libraries with the firm knowledge that no extant program will be ''broken'' in the process.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)