Skip to content

Instantly share code, notes, and snippets.

@andreiglingeanu
Created May 5, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreiglingeanu/3a460bdf4bd239114362f7a1ca73da1c to your computer and use it in GitHub Desktop.
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`.
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