Category:M2000 Interpreter: Difference between revisions

Content added Content deleted
No edit summary
 
Line 20: Line 20:




M2000 start as an experimental interpreted language, using a Module in Module idea (like a Procedure in Procedure) where each inner Module is closed for modification, but open for expansion, by replacing code at run time. Code executed in one pass. There is a low range pass to determine the major type of an expression, a number or a string. Look this paradigm: We call inner Beta in two stages. At the second stage we change inner Theta with Theta2. This is the decoration of Beta with Theta as Theta2. This is a temporary decoration because Beta after execution erase any new identifier including Theta. So each time we call Beta, statement Module Theta make this module unless a decoration stop it.
M2000 start as an experimental interpreted language, using a Module in Module idea (like a Procedure in Procedure) where each inner Module is closed for modification, but open for expansion, by replacing code at run time. Source code executed as is, without second interpretation of a simple form, although block of code arranged for execution in a manner of consuming code (code which executed deleted, code in a loop kept as a copy for next iteration).

==English Vocabulary==
Module's may be Global, or local to other modules. We can define global modules in a module, and all these definitions deleted at the end of module execution. Because we have to execute the definition of a module, we can select definition, or load definition before we call the module. Also modules can be part of object's of type Group. A module can't call itself unless we use Call module_name. The standard call is by using only the name of module. So from a module we can call local modules or global, but we can't call parent module (if isn't global). In a group we can call anything like a module plus the modules of the groups.

We can change a inner module at the calling of a module, see the example: We call inner Beta in two stages. At the second stage we change inner Theta with Theta2. This is the decoration of Beta with Theta as Theta2. This is a temporary decoration because Beta after execution erase any new identifier including Theta. So each time we call Beta, statement Module Theta make this module unless a decoration stop it.

====English Vocabulary====
<syntaxhighlight lang="m2000 interpreter">Module Beta {
<syntaxhighlight lang="m2000 interpreter">Module Beta {
Module Theta (x){
Module Theta (x){
Line 34: Line 39:
Beta ; Theta as Theta2
Beta ; Theta as Theta2
</syntaxhighlight>
</syntaxhighlight>
==Greek Vocabulary==
====Greek Vocabulary====
<syntaxhighlight lang="m2000 interpreter">Τμήμα Βήτα {
<syntaxhighlight lang="m2000 interpreter">Τμήμα Βήτα {
Τμήμα Θήτα (χ){
Τμήμα Θήτα (χ){
Line 48: Line 53:




As we can see from code, some statements are like BASIC, except the use of curly brackets {}. Check the code below. We have a Module (as a Procedure), where we define some functions and some variables, as entities. These entities defined in every call to CheckIt, and erased when execution return from CheckIt. By default every parameter in M2000 pass by value. We define two functions, Alfa() where we set type for parameter x and ExpType$() where we not set type for x, and we wish to return the name of type when we make a call. Using DEF we can define variables and functions (in one line).
As we can see from code, some statements are like BASIC, except the use of curly brackets {}. Check the code below. We have a Module (as a Procedure), where we define some functions and some variables, as entities. These entities defined in every call to CheckIt, and erased when execution return from CheckIt. By default every parameter in M2000 pass by value. We define two functions, Alfa() where we set type for parameter x and ExpType$() where we not set type for x, and we wish to return the name of type when we make a call.


<syntaxhighlight lang="m2000 interpreter">Module CheckIt {
<syntaxhighlight lang="m2000 interpreter">Module CheckIt {
Line 60: Line 65:
M=Alfa(3)
M=Alfa(3)
Print Type$(M) ' Double
Print Type$(M) ' Double
\\ Def can create once Z (second time raise error)
double z // new from version 12
Def Z as Double
\\ If a variable get a type then any number convert to that type before assign to it
\\ If a variable get a type then any number convert to that type before assign to it
Z=121212112.11212@
Z=121212112.11212@
Print Type$(Z)
Print Type$(Z)
Def Currency Z1=212.12, Z2=323233.12, Z3=223212323323.12
Currency Z1=212.12, Z2=323233.12, Z3=223212323323.12
Print Z1, Z2, Z3
Print Z1, Z2, Z3
Def ExpType$(x)=Type$(x)
Def ExpType$(x)=Type$(x)
Line 79: Line 83:
CheckIt
CheckIt
\\ Now Function Alfa and all variables erased.
\\ Now Function Alfa and all variables erased.
\\ We can call it again
// We can call it again
CheckIt</syntaxhighlight>
CheckIt</syntaxhighlight>




For small programs, for learning algorithms there is no need to use types, except the major types, Numeric and String, plus one more: Integer. Integers can be number types like Long and Integer types, or can be any numeric type using without decimal part. So Integer variables are variables with % at the end of their name. String Variable need a $ at the end of name.
For small programs, for learning algorithms there is no need to use types, except the major types, Numeric and Strings, plus one more: Integer. Integers can be number types like Long and Integer types, or can be any numeric type using without decimal part. So Integer variables are variables with % suffix on their name. String Variable can use a $ suffix. From version 12 we can use string variables without suffix. Although the interpreter own string functions use suffix $ (like str$()).


For Expressions before execution automatic check by names if the result can be for strings names, or for numeric names. A string name has $ at the end of name. Maybe a string name isn't a string, because with same name we can define groups which get or and return strings values. A statement Input Alfa$ can input characters for a string or for object typed group with that name. Interpreter implicitly use the appropriate method. If name has no $ at the end then this can be an object or a numeric value. A Input Beta may return error if Beta has no numeric value to set.
A statement Input Alfa$ can input characters for a string or for object typed group with that name. Interpreter implicitly use the appropriate method.


Types are strong for values with a name (variables, constants), but weak for items in containers. In a container (Array, Inventory and Stack) we can place anything including other containers. We can bypass the "strong" capability but this isn't a practice for good programming. Internal or variables are of type of Variant, so we can make a reference of A to A$ and we can save a string "1212" and read from A the number 1212.
Types are strong for values with a name (variables, constants), but weak for items in containers. In a container (Array, Inventory and Stack) we can place anything including other containers. We can bypass the "strong" capability but this isn't a practice for good programming. Internal or variables are of type of Variant, so we can make a reference of A to A$ and we can save a string "1212" and read from A the number 1212.