Mumpster http://mumpster.org/ |
|
Unit 2 - Lesson 3: Expressions – Overview http://mumpster.org/viewtopic.php?f=29&t=790 |
Page 1 of 1 |
Author: | tlwiechmann [ Sun May 29, 2011 8:46 am ] |
Post subject: | Unit 2 - Lesson 3: Expressions – Overview |
Because this lesson is very large, it will be given in parts. The diagram shown on the first page of the Expression lesson depicts the structure of an expression as it is defined in the standard. Each level will be presented as a lesson. An overview of each lesson is given below. The definition of an expression as given by the standard is: “The expression, expr, is the syntactic element which denotes the execution of a value-producing calculation. Expressions are made up of expression atoms separated by binary, arithmetic, or truth-valued operators.” The standard goes into great depths to explain the concept. We will not. Let it suffice to say that the expression is very powerful and recursively defined. What is recursion? Simply stated, it means you can use an expression within an expression. ASCII Character Set The expression definition begins with the default ASCII characters set. The MUMPS language is constructed from this character set. By default all MUMPS implementations are based upon the character set. Some implementation permit data that is based on the UTF-8 character set (http://en.wikipedia.org/wiki/UTF-8) which is a requirement if you are going to do Web work. ASCII is a subset of UTF-8. Data Type: String MUMPS has one data type, the String. Strings consist of a collection of characters including the empty set. When a string is used within a command context, the context may required the string to produce a numeric value or a truth value. For example, if a string is used within an arithmetic operation, only the leading numbers up to the first non-numeric character will be used in the operation (now review the Teaser in the Extrinsic Variables section of the previous lesson). If the string is used in a truth value producing context, a zero (false) or nonzero(true) number will be produced. In other words, what a string evaluates to depends upon the context of evaluation. Symbol Names MUMPS strings are associated with names producing Name Value relationships. There are three levels of Name Value types: Symbols, Arrays and Functions. Symbols are also referred to as variables when the value is settable (can change). Symbols consist of:
Arrays extend the concept of symbol names by adding subscripting capabilities. For example: ^PAT(345678,”Name”)=”Doe, John” This is a persistent array (global) node whose first subscript is the number 345678 and second subscript is the literal “Name”. This node is bound to the string “Doe, John” Arrays form the basis for the MUMPS database. We will spend a great deal of time with them. Functions Functions are used to produce values given one or more input parameters. There are a number of functions that need to be covered – all of them important. Indirection The MUMPS language is a powerful string handing language. However, without Indirection, you would be confined to writing what I call “literal” programs. That is, if you had to write a patient data entry program and an accounts receivable entry program, you would have to literally write two complete sets of programs. Indirection permits you to implement the commonality between the two programs as one set of code that is typically table driven. Programs like File Manager and EsiObjects would be extremely hard (if not impossible) to write without the aid of Indirection. Having said that, working with Indirection can be confusing and abstract. We will not elaborate on it in this course. It is elaborated upon greatly (almost exclusively) in the MUMPS Programming II course. Operators Operators are the glue that pulls together the language elements listed above to form an expression. We will cover and use them extensively. |
Page 1 of 1 | All times are UTC - 8 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |