You can edit almost every page by Creating an account. Otherwise, see the FAQ.

M2000 Interpreter

From EverybodyWiki Bios & Wiki

Orientation[edit]

Since 2003[1] a new programming language, as a stable implementation begins. It started as a procedural and BASIC like language to evolved to an Object Oriented Language, with Lambda functions using closures, events and threads[2]. This Language tis argeting the education by prototyping pupils ideas,so name get the M from M2000 from Greek Μαθητής (pupil).

Overview[edit]

M2000 is a dynamic language, where everything stay alive, from when it declare, in a parent, until that parent ends of execution. Exception exist for floating Groups (the objects of M2000), which can carry values and code out from where they instantiate, and for lambda functions. All variables are local, except those we declared as global, but local and global stay alive until the end of execution of parent. Parent is a module (like a procedure) or a function, which by default isolate variables from siblings inner or outer, or can be a Sub or a For Object Block, which they have same lexical visibility with module or function where belongs but erase any new variable as modules and functions at the end of execution. Modules may have modules(global or local), functions (global or local), subs (are always local), and Groups and static variables, local variables, and code. A Group can be global or local, as a named group, has properties, variables, operators, modules, functions and other groups inside. Every module and function in a group can see private and public variables, and public properties. Properties are groups which control how we assign value and how we get value, and we can add anything a group can get.

Syntax[edit]

Syntax of language is like BASIC, with the use of curled brackets {}, for block of codes, plus other additions. Calling a user function always done without interpreter check at the calling part the type and amount of arguments. Its Function's part responsible to do whatever with the passing arguments. Passing of arguments are by value, by default and uses a stack of values. At the Function's code, we have to Read these values, popping from that stack. Breaking the passing of arguments in two stages, the feeding of stack and the reading of stack, can be give interesting examples of codes. We can use code to inspect the type of values in stack and do whatever we want.

Module CheckIt {
      Declare Simple Form
      With Simple, "Title" as t$
      t$= "Hello Form"
      Function Simple.Click {
                  If Ask("Hello World") then t$= "Hello World"
      }
      Method Simple, "Show", 1
      Declare Simple Nothing
}
CheckIt

Values Containers[edit]

Except of main objects, the Groups, M2000 use containers, Arrays, Inventories (a kind of vectors) and Stacks (a kind of FIFO and LIFO, we can add in both end, using Push for top and Data for bottom, but we pop from one only, from top). Stack of values is a Stack Container, and each module run in an execution object which has a reference to parent stack. Each call to a module pass this reference, so at return from call maybe we can use it to get a number of values as "answers". Each call to a user function pass a new stack, with arguments and destroy it at the end. Functions can return more than one value packed them in an array container, and pass a pointer to array for return value. Function can return any type of value, including Groups as values, and can return pointers to containers and pointers to groups.

Memory Blocks/Pointers[edit]

There is a different container than normal, the Buffer, which hold memory block and we can assign a structure (with structures and unions inside). Buffers can be used for passing values and true memory pointers to C dlls. M2000 can use COM Objects (like MS Word), and system dll, plus C dll.

Environment[edit]

M2000 Environment is an Open Source project, written in Visual Basic 6, with a console for text and graphics and a window manager for user forms, with a small set of controls, plus a thread system, to execute code of modules in a Sequential or Concurrent Plan. Code executed as is, one pass interpreter, which means is not fast, but can be run showing in a test form each statement as executed, including statements in threads.

Examples[edit]

There are many examples in Rosettacode.org. Source Code for Environment, and examples GitHub Wiki

References[edit]

  1. Καρράς, Γιώργος (2003). Cite this Email this Export Record Add to Favorites Μ 2000 Γλώσσα προγραμματισμού : Ελληνικές εντολές, γραφικά, βάσεις δεδομένων, πολυμέσα [Ηλεκτρονικός πόρος] (1 ed.). Preveza, Greece: Φωτοκίνηση. ISBN 960-87618-0-8. Retrieved 19 July 2018. Search this book on
  2. Οικονομίδης, Κυριάκος. "owner". www.dwrean.net. Retrieved 28 September 2015.


This article "M2000 Interpreter" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:M2000 Interpreter. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.