<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://gammapedia.kuschelyagi.com/index.php?action=history&amp;feed=atom&amp;title=User%3AAbwayax%2FAbwayax_programming_language%2FTutorial</id>
	<title>User:Abwayax/Abwayax programming language/Tutorial - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://gammapedia.kuschelyagi.com/index.php?action=history&amp;feed=atom&amp;title=User%3AAbwayax%2FAbwayax_programming_language%2FTutorial"/>
	<link rel="alternate" type="text/html" href="https://gammapedia.kuschelyagi.com/index.php?title=User:Abwayax/Abwayax_programming_language/Tutorial&amp;action=history"/>
	<updated>2026-06-19T19:21:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://gammapedia.kuschelyagi.com/index.php?title=User:Abwayax/Abwayax_programming_language/Tutorial&amp;diff=5818&amp;oldid=prev</id>
		<title>24.243.13.121 at 08:21, 10 November 2007</title>
		<link rel="alternate" type="text/html" href="https://gammapedia.kuschelyagi.com/index.php?title=User:Abwayax/Abwayax_programming_language/Tutorial&amp;diff=5818&amp;oldid=prev"/>
		<updated>2007-11-10T08:21:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Hello world program==&lt;br /&gt;
 println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
As you can see it is pretty much the same as in many other languages.&lt;br /&gt;
&lt;br /&gt;
==Variable assignment and usage==&lt;br /&gt;
A variable is a name associated with a value. A variable consists of a name prefixed with a symbol that denotes what type the variable is. The five basic data types are &amp;#039;&amp;#039;&amp;#039;scalar&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;array&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;hash&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;function&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;object&amp;#039;&amp;#039;&amp;#039; (the last two are covered later)&lt;br /&gt;
 $string = &amp;quot;This is a string.&amp;quot;; // The $ denotes a scalar (string or number) value.&lt;br /&gt;
 @array = [&amp;quot;This&amp;quot;,&amp;quot;is&amp;quot;,&amp;quot;an&amp;quot;,&amp;quot;array&amp;quot;]; // The @ denotes an array (a collection of values stored under one variable name)&lt;br /&gt;
 %hash = [&amp;quot;one&amp;quot; =&amp;gt; 1, &amp;quot;two&amp;quot; =&amp;gt; 2, &amp;quot;three&amp;quot; =&amp;gt; 3]; // The % denotes a hash (or associative array; a collection of values associated with string keys)&lt;br /&gt;
 &lt;br /&gt;
 println($string); // prints out This is a string.&lt;br /&gt;
 &lt;br /&gt;
 println(@array); // prints out [This,is,an,array]&lt;br /&gt;
 println(@array[0]); // prints out This&lt;br /&gt;
 println(@array[1]); // prints out is&lt;br /&gt;
  &lt;br /&gt;
 println(%hash); // prints out something like {one=1,two=2,three=3}&lt;br /&gt;
 println(%hash[&amp;quot;one&amp;quot;]); // prints out &amp;quot;one&amp;quot;&lt;br /&gt;
 println(%hash[&amp;quot;two&amp;quot;]); // prints out &amp;quot;two&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 $one = %hash[&amp;quot;one&amp;quot;]; // $one now equals 1&lt;br /&gt;
 @array[0] = %hash[&amp;quot;two&amp;quot;]; // this is also permissible; @array now holds [2,is,an,array]&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;function&amp;#039;&amp;#039;&amp;#039; is a subprogram that can be executed by calling its name and giving it parameters. Abwayaxlanguage considers functions to be data just like scalars, hashes, etc. Accordingly, they are defined by assigning them to a function variable, like so:&lt;br /&gt;
 &amp;amp;foo = { // The &amp;amp; denotes a function variable&lt;br /&gt;
     println(&amp;quot;Foo&amp;quot;);&lt;br /&gt;
 }; // Note the semicolon after the closing brace; most languages do not require this, but abwayaxlanguage does&lt;br /&gt;
After defined, the function &amp;lt;tt&amp;gt;foo()&amp;lt;/tt&amp;gt; can be called at any time:&lt;br /&gt;
 foo(); // prints out Foo&lt;br /&gt;
Like any other piece of data, functions can be stored in arrays or hashes, like so:&lt;br /&gt;
 %funcmap = [&lt;br /&gt;
     &amp;quot;One&amp;quot; =&amp;gt; { println(&amp;quot;one&amp;quot;) },&lt;br /&gt;
     &amp;quot;Two&amp;quot; =&amp;gt; { println(&amp;quot;two&amp;quot;) },&lt;br /&gt;
     &amp;quot;Three&amp;quot; =&amp;gt; { println(&amp;quot;three&amp;quot;)&lt;br /&gt;
  ];&lt;br /&gt;
Functions without their own function variable are called with the &amp;lt;tt&amp;gt;call()&amp;lt;/tt&amp;gt; function, which takes a function as a parameter:&lt;br /&gt;
 call(%funcmap[&amp;quot;One&amp;quot;]); // calls the one function&lt;br /&gt;
===Parameters===&lt;br /&gt;
Functions usually take one or more &amp;#039;&amp;#039;&amp;#039;parameters&amp;#039;&amp;#039;&amp;#039;. A parameter is a value passed to a function, with which the function is expected to do something. Examples of paramters earlier in the tutorial include the strings passed to the &amp;lt;tt&amp;gt;println()&amp;lt;/tt&amp;gt; function, which prints a line to the console, and the function passed to the &amp;lt;tt&amp;gt;call()&amp;lt;/tt&amp;gt; function. In the body of the function, parameters are accessed through the built-in &amp;lt;tt&amp;gt;@args&amp;lt;/tt&amp;gt; array.&lt;br /&gt;
 &amp;amp;funcWithParams = {&lt;br /&gt;
     println(@args[0]); // prints out the first parameter given to it&lt;br /&gt;
 };&lt;br /&gt;
Alternatively, you may use the &amp;lt;tt&amp;gt;list()&amp;lt;/tt&amp;gt; function to assign names to the arguments. &amp;lt;tt&amp;gt;list()&amp;lt;/tt&amp;gt; takes an argument followed by a number of strings; the values are taken from the array and assigned to variables with the names given.&lt;br /&gt;
 &amp;amp;funcWithParams = {&lt;br /&gt;
     list(@args,&amp;quot;myParam&amp;quot;); // @args[0] is now assigned to $myParam&lt;br /&gt;
     println($myParam);&lt;br /&gt;
 };&lt;br /&gt;
To call this function, you would use the following line:&lt;br /&gt;
 funcWithParams(&amp;quot;Hi there&amp;quot;); // prints out Hi there&lt;br /&gt;
===Return===&lt;br /&gt;
Usually, a function is expected to &amp;#039;&amp;#039;&amp;#039;return&amp;#039;&amp;#039;&amp;#039; something; that is, calling it will give a value that can be used in an expression. Consider the following function, which adds two numbers:&lt;br /&gt;
 &amp;amp;addTwoNums = {&lt;br /&gt;
     list(@args,$num1,$num2);&lt;br /&gt;
     return $num1 + $num2;&lt;br /&gt;
 };&lt;br /&gt;
Now we can use the function whenever we need to add two numbers, such as:&lt;br /&gt;
 $twentySeven = addTwoNums(20,7); // returns 27&lt;br /&gt;
==Objects==&lt;br /&gt;
An &amp;#039;&amp;#039;&amp;#039;object&amp;#039;&amp;#039;&amp;#039; is an entity that contains pieces of data and functions that act on that data. Typical example of declaring an object:&lt;br /&gt;
 *object = Object(); // * denotes an object&lt;br /&gt;
 *object-&amp;gt;ctr = 0; // -&amp;gt; is the object member access operator&lt;br /&gt;
 *object-&amp;gt;increment = { *this-&amp;gt;ctr = *this-&amp;gt;ctr + 1; };&lt;br /&gt;
 finalize(*object);&lt;br /&gt;
 &lt;br /&gt;
 *object-&amp;gt;increment(); // raises *object-&amp;gt;ctr to 1&lt;br /&gt;
 *object-&amp;gt;increment(); // raises it to 2&lt;br /&gt;
Our object &amp;lt;tt&amp;gt;*object&amp;lt;/tt&amp;gt; has a &amp;#039;&amp;#039;&amp;#039;field&amp;#039;&amp;#039;&amp;#039; called &amp;lt;tt&amp;gt;ctr&amp;lt;/tt&amp;gt; and a function (or &amp;#039;&amp;#039;&amp;#039;method&amp;#039;&amp;#039;&amp;#039;) called &amp;lt;tt&amp;gt;increment()&amp;lt;/tt&amp;gt;. Each call to &amp;lt;tt&amp;gt;increment()&amp;lt;/tt&amp;gt; increases &amp;lt;tt&amp;gt;ctr&amp;lt;/tt&amp;gt; by 1. The function &amp;lt;tt&amp;gt;finalize()&amp;lt;/tt&amp;gt; marks the object as &amp;lt;tt&amp;gt;final&amp;lt;/tt&amp;gt; any further modification to the structure of the object outside its own scope (methods within the object ignore the &amp;lt;tt&amp;gt;final&amp;lt;/tt&amp;gt; flag).&lt;br /&gt;
===Constructor===&lt;br /&gt;
Unless you plan to use a type of object only once in the code, it might help to define a &amp;#039;&amp;#039;&amp;#039;constructor&amp;#039;&amp;#039;&amp;#039; to create the object. A constructor is merely a function that creates and returns an object. Here is what a constructor for our &amp;lt;tt&amp;gt;*object&amp;lt;/tt&amp;gt; might look like:&lt;br /&gt;
 &amp;amp;myObject = {&lt;br /&gt;
     *object = Object();&lt;br /&gt;
     *object-&amp;gt;ctr = 0;&lt;br /&gt;
     *object-&amp;gt;increment = { *this-&amp;gt;ctr = *this-&amp;gt;ctr + 1; };&lt;br /&gt;
     finalize(*object);&lt;br /&gt;
     return *object; &lt;br /&gt;
 };&lt;br /&gt;
The constructor lets you easily create objects of this type (or &amp;#039;&amp;#039;&amp;#039;instances&amp;#039;&amp;#039;&amp;#039;). In some ways one might say it acts almost like a &amp;quot;class&amp;quot;. Now, anyone wishing to create a &amp;lt;tt&amp;gt;myObject()&amp;lt;/tt&amp;gt; must simply invoke the function:&lt;br /&gt;
 *object = myObject();&lt;br /&gt;
 *object2 = myObject();&lt;br /&gt;
 *object-&amp;gt;increment(); // affects only *object and not *object2&lt;br /&gt;
==If==&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;if statement&amp;#039;&amp;#039;&amp;#039; is a universally used statement to control program execution. It tests to see if a condition is true; if so, then it executes a statement or block of statements; else, it does not. In abwayaxlanguage, if looks like this:&lt;br /&gt;
 if(condition) {&lt;br /&gt;
    // code&lt;br /&gt;
 }; // note the semicolon&lt;br /&gt;
An example of if is as follows:&lt;br /&gt;
 if(2 + 2 == 5)&lt;br /&gt;
     println(&amp;quot;Two and two make five.&amp;quot;);&lt;br /&gt;
In this example, the &amp;lt;tt&amp;gt;println&amp;lt;/tt&amp;gt; is executed if and only if 2 + 2 equals 5 (which it doesn&amp;#039;t).&lt;/div&gt;</summary>
		<author><name>24.243.13.121</name></author>
	</entry>
</feed>