Τρίτη 24 Οκτωβρίου 2017

Αναθεώρηση 43, Έκδοση 8.9

Σε συνέχεια από την προηγούμενη αναθεώρηση. Εδώ έγινε έλεγχος και διορθώθηκε η περίπτωση να καλέσουμε μια συνάρτηση με αναφορά.
Στο πρώτο πρόγραμμα η συνάρτηση είναι εκτός από οποιοδήποτε Group. Την καλούμε και μέσα στο Delta.Look και έξω από αυτό. 


Module global tsekme {
      Read &n
      Try {
            \\ operator "lost" in reference (in previous revisions)
            n++
      }
      Print"check it", n
}
Class Alfa {
      Property X=10
      Group X {
            operator "++" {
                  Link parent [X] to X
                  X++
            }
      }
      Property Y=5
      Module TestMe {
            \\  .[X] is a value
            \\ .X is a group which we can read or write, or read and write
            Print .[X], .[Y]
      }
}
Function OutOfGroup {
            Read New Beta
            Beta2=Alfa()
            Group Beta3 {
                  Property X=10
                  Property Y=5
            }
            Beta.X<=500
            Beta.X++
\\            List !
            Print Beta.X, Beta2.X, Beta3.X
            Beta.TestMe
            Beta3=Beta
            Beta3.TestMe
            tsekme &Beta3.X
            Push Beta3
\\            List!
}
Group Delta {
      Module Look {
            Read &func()
            ' group is in stack for values
             ' Calling a function with CALL we place current stack to it
            Call func()
      }
}
Global Beta=Alfa()
Beta.X<=2000
Delta.Look &OutOfGroup(), Alfa()
Read BetaFinal
Call OutOfGroup(Alfa())
Read BetaFinal
Print Beta.X, BetaFinal.X


Παρακάτω είναι η περίπτωση με την συνάρτηση να είναι μέσα σε ένα Group, το SomethingElse. Εδώ έχουμε την SomethingElse.Μ να αυξάνει κάθε φορά που καλούμε την συνάρτηση SomethingElse.InAGroup(). Και εδώ καλούμε την συνάρτηση μέσα στο Delta.Look και έξω από αυτό.

Module global tsekme {
      Read &n
      Try {
            \\ operator "lost" in reference (in previous revisions)
            n++
      }
      Print"check it", n
}
Class Alfa {
      Property X=10
      Group X {
            operator "++" {
                  Link parent [X] to X
                  X++
            }
      }
      Property Y=5
      Module TestMe {
            \\  .[X] is a value
            \\ .X is a group which we can read or write, or read and write
            Print .[X], .[Y]
      }
}
Group SomethingElse {
      M=10
      Function inAGroup {
                  .M++
                  Read New Beta
                  Beta2=Alfa()
                  Group Beta3 {
                        Property X=10
                        Property Y=5
                  }
                  Beta.X<=500
                  Beta.X++
'                 List !
                  Print Beta.X, Beta2.X, Beta3.X
                  Beta.TestMe
                  Beta3=Beta
                  Beta3.TestMe
                  tsekme &Beta3.X
                  Push Beta3
'                  List!
      }
}
Group Delta {
      Module Look {
            Read &func()
            ' group is in stack for values
             ' Calling a function with CALL we place current stack to it
            Call func()
      }
}
Global Beta=Alfa()
Beta.X<=2000
Print SomethingElse.M
Delta.Look &SomethingElse.inAGroup(), Alfa()
Read BetaFinal
Print SomethingElse.M
Call SomethingElse.inAGroup(Alfa())
Read BetaFinal
Print Beta.X, BetaFinal.X






Η τρίτη περίπτωση είναι να έχουμε μια συνάρτηση μέσα στο Delta.Look

Module global tsekme {
      Read &n
      Try {
            \\ operator "lost" in reference (in previous revisions)
            n++
      }
      Print"check it", n
}
Class Alfa {
      Property X=10
      Group X {
            operator "++" {
                  Link parent [X] to X
                  X++
            }
      }
      Property Y=5
      Module TestMe {
            \\  .[X] is a value
            \\ .X is a group which we can read or write, or read and write
            Print .[X], .[Y]
      }
}
Group Delta {
      Module Look {
            Function InsideGroupModule {
                  Read New Beta
                  Beta2=Alfa()
                  Group Beta3 {
                        Property X=10
                        Property Y=5
                  }
                  Beta.X<=500
                  Beta.X++
      \\            List !
                  Print Beta.X, Beta2.X, Beta3.X
                  Beta.TestMe
                  Beta3=Beta
                  Beta3.TestMe
                  tsekme &Beta3.X
                  Push Beta3
      \\            List!
      }
                  ' group is in stack for values
                   ' Calling a function with CALL we place current stack to it
            Call InsideGroupModule()
            }

}
Global Beta=Alfa()
Beta.X<=2000
Delta.Look Alfa()
Read BetaFinal
Print Beta.X, BetaFinal.X



 Η τέταρτη περίπτωση είναι να έχουμε στο Group Delta μια συνάρτηση μέλος του:

Module global tsekme {
      Read &n
      Try {
            \\ operator "lost" in reference (in previous revisions)
            n++
      }
      Print"check it", n
}
Class Alfa {
      Property X=10
      Group X {
            operator "++" {
                  Link parent [X] to X
                  X++
            }
      }
      Property Y=5
      Module TestMe {
            \\  .[X] is a value
            \\ .X is a group which we can read or write, or read and write
            Print .[X], .[Y]
      }
}
Group Delta {
      Function InsideGroup {
            Read New Beta
            Beta2=Alfa()
            Group Beta3 {
                  Property X=10
                  Property Y=5
            }
            Beta.X<=500
            Beta.X++
\\            List !
            Print Beta.X, Beta2.X, Beta3.X
            Beta.TestMe
            Beta3=Beta
            Beta3.TestMe
            tsekme &Beta3.X
            Push Beta3
\\            List!
      }
      Module Look {

                  ' group is in stack for values
                   ' Calling a function with CALL we place current stack to it
            Call .InsideGroup()
      }

}
Global Beta=Alfa()
Beta.X<=2000
Delta.Look Alfa()
Read BetaFinal
Print Beta.X, BetaFinal.X









Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.