Last active
November 13, 2019 20:49
-
-
Save okram/156672609c818584fb13b9f3b6bbf072 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// type checking/inference | |
// The result is the compiled bytecode which shows the types for nested sequences | |
mmadt> obj{0} <= [start,int][plus,5][mult,5][is,[gt,5]][plus,100][is,[mult,45][minus,10][gt,0]] | |
==>int{?} <= [start,int][plus,5][mult,5][is,bool <= [gt,5]][plus,100][is,bool{?} <= [mult,45][minus,10][gt,0]] | |
// instance execution | |
// take the resultant instruction above and plug in 10 for int at the [start] | |
mmadt> int{?} <= [start,10][plus,5][mult,5][is,bool <= [gt,5]][plus,100][is,bool{?} <= [mult,45][minus,10][gt,0]] | |
==>175 | |
mmadt> int{?} <= [start,-10][plus,5][mult,5][is,bool <= [gt,5]][plus,100][is,bool{?} <= [mult,45][minus,10][gt,0]] | |
mmadt> | |
// Thus, the type was right, int{?} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment