Euphoria is an interpreted programming language conceived and created by Robert Craig of Rapid Deployment Software.
It was developed with the following design goals in mind:
The name "Euphoria" itself is an acronym for "End-User Programming with Hierarchical Objects for Robust Interpreted Applications", although there is some suspicion that this is in fact a backronym.
The first world-visible incarnation of the language was for the 32-bit DOS platform and was released in July of 1993. The original Atari version, to date, has not been released.
Current versions support 32-bit DOS, Windows, Linux, and FreeBSD. There is also a translator to convert Euphoria code into C for compilation to native machine code and what is known as the Binder, which binds the Euphoria source code to the interpreter to make an executable instead of machine compiling.
With the release of version 2.5 the Euphoria interpreter was split into two sections: the front-end parser and the back-end interpreter. The front-end is now written in Euphoria instead of C and was released as open source. The front-end is also used with the Euphoria-to-C translator and the Binder.
Euphoria source code can be "bound" to the Euphoria run-time code to produce a stand-alone program for distribution. The code may also be "shrouded" to prevent others from viewing, copying, or changing the source.
You can also use the Euphoria-to-C translator to convert your Euphoria source code into C source code and then compile it into machine language. Using this technique, you can create stand-alone programs as well as Windows DLL files.
Additionally, Euphoria has two specialized data types:
There is no character string data type, as these are represented by a sequence of integer values. However, because literal strings are so commonly used in programming, Euphoria interprets double-quote enclosed characters as a sequence of integers. Thus
"ABC"
is seen as if the coder had written:
{'A', 'B', 'C'}
which is the same as:
{65,66,67}
As brief examples, the following code
global function delete_item( object old, sequence group ) integer pos -- Code begins -- pos = find( old, group ) if pos > 0 then group = group.. pos-1 & group.. length( group ) end if return group end function
looks for an old item in a group of items. If found, it removes it by concatenating all the elements prior to it with all the elements after it. The result is then returned. Note that elements in sequences are 1-based indexed. This means that the first element has an index of 1.
Simplicity is apparent in that the code clearly delineates its constructs with words. Instead of braces, semicolons, and question marks, you see phrases like 'if..then', 'end if', and 'end function'.
Flexibility is present; the item 'old' could be strings, numbers, images, or whole collections of data themselves. A different function for each data type isn't needed, nor does the programmer have to check the data types. This function will work with any sequence of data of any type, and requires no external libraries.
global function replace_item( object old, object new, sequence group ) integer pos -- Code begins -- pos = find( old, group ) if pos > 0 then group* = new end if return group end function
Safety is present due to the fact that there are no pointers involved and subscripts are automatically checked. Thus the function cannot access memory out-of-bounds, and cannot go beyond the end of the sequence or before the beginning of it to corrupt the memory. There is no need to explicitly allocate or deallocate memory, and no chance of a leak.
The line
group = group.. pos-1 & group.. length( group )
shows some of the sequence handling facilities. A sequence can contain a collection of any types, and this can be sliced (to take a subset of the data in a sequence) and concatenated in expressions, with no need for special functions.
Version 2.5 introduces the new '$' symbol, which is used for "length(sequence)." So, the above example could be written in 2.5 as follows:
group = group.. pos-1 & group.. $
Euphoria (Programmiersprache) | Euphoria | Euphoria | Euphoria
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Euphoria programming language".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world