Created
May 5, 2017 20:34
-
-
Save andreiglingeanu/3a460bdf4bd239114362f7a1ca73da1c to your computer and use it in GitHub Desktop.
Classes in Mozart lang. Here we define `NewCounter` class and two objects named `Ctr1` and `Ctr2`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
fun {NewCounter} | |
C Bump Read in | |
C = {NewCell 0} | |
fun {Bump} | |
C := @C + 1 | |
@C | |
end | |
fun {Read} | |
@C | |
end | |
counter(bump:Bump read: Read) | |
end | |
declare | |
Ctr1={NewCounter} | |
Ctr2={NewCounter} | |
{Show Ctr1} | |
{Show {Ctr1.bump}} | |
{Show {Ctr2.bump}} | |
{Show {Ctr2.bump}} | |
{Show {Ctr2.bump}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment