BETA (programming language): Difference between revisions

Content deleted Content added
Slight reformatting and introduction
Features: Basic explanation of patterns
Line 31:
 
BETA supports the object-oriented perspective on programming and has comprehensive facilities for procedural and functional programming. It has powerful abstraction mechanisms to support identification of objects, classification and composition. BETA is a statically typed language like Simula, [[Eiffel (programming language)|Eiffel]] and [[C++]], with most type checking done at compile-time. BETA aims to achieve an optimal balance between compile-time type checking and run-time type checking.
 
===Patterns===
 
A major and peculiar feature of the language is the concept of patterns. In another programming language, such as [[C++]], one would have several classes and procedures. BETA expresses both of these concepts using patterns.
 
For example, a simple class in C++ would have the form
<source lang="cpp">
class point {
int x, y;
};
</source>
In BETA, the same class could be represented by the pattern
<pre>
point: (#
x, y: @integer
#)
</pre>
That is, a class called ''point'' will have two fields, ''x'' and ''y'', of type [[integer]]. The symbols ''(#'' and ''#)'' introduce patterns. The colon is used to declare patterns and variables. The ''@'' sign before the integer type in the field definitions specifies that these are integer fields, and not, by contrast, references, arrays or other patterns.
 
On the other hand, a procedure in C++ could have the form
<source lang="cpp">
int max(int x, int y)
{
if(x >= y)
{
return x;
}
else
{
return y;
}
}
</source>
In BETA, such a function could be written using a pattern
<pre>
max: (#
x, y, z: @integer
enter (x, y)
do
(if x >= y // True then
x -> z
else
y -> z
if)
exit z
#)
</pre>
 
===Hello world!===