Guests
You should really register. It's free, you will become a respected member of the community and you'll be allowed to access much more of the forum.

Themes
We have many forum themes. Pick one from the drop down box at the bottom of every page for a quick change!


[-]
UserID: -
(This will display a message for the specified user, telling him you want to talk to him)
Shout: -
User Panel
Loading...
Smilies
PopupSB
MyCode
Colors

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The 12 Data Types
01-08-2010, 09:17 AM (This post was last modified: 01-08-2010 09:20 AM by Beefster.)
Post: #1
The 12 Data Types
Object (obj, object)
As the base class, it has no inherent properties, but some casting methods. All variables are objects- the default type.
Code:
obj my_obj = 8;

Function (vars: fun, func, function; definitions: type def)
Function objects reference code that will be run when called. This allows functions to easily be passed into other functions as arguments. You can still call functions directly.
Code:
int def myfunc(obj myarg);
!-code goes here
/def;

Classes (vars: ???; definitions: class)
Class variables point to a class and can be run to construct objects. These implement everything to do with type and manage inheritance.
Code:
class MyClass inherits from int, string;
!- Bleh
/class;

Numbers (num, number)
This is the base class for Booleans, Integers, and Floats. All numbers are freely castable between each other.
Code:
num my_num = false;

Boolean (bool, boolean)
These numbers can assume one of two values: true and false. When cast from other number types, only a 0 (or null) becomes false; everything else evaluates true. When cast to other number types, a 1 is true and a 0 is false. (which isn't allowed in most other programming languages)
Code:
bool my_bool = true;

Integer (int, integer)
These numbers can hold any integer value. Implementation changes based upon the current value.
Code:
int my_int = 27;

Float (float)
Also known as "Floating point" numbers, these can represent up to about 15 digits of a decimal number. There are no small (4-byte) floats, only doubles (8 bytes) because there is no significant difference of RAM usage when considering the VM's overhead usage for storing variables.
Code:
float avagadros_number = 6.02e23;

Sequence (seq, sequence)
Yet another base class. Wraps Strings, Arrays, and Lists. All sequences are zero-indexed. Like numbers, all sequences are freely inter-castable.
Code:
seq my_seq = [1,2,3,5];

String (str, string)
This stores textual information. Unlike C++ or Python, strings are completely mutable, which means that you can insert, change, or remove any text you would like. Supports some operators similar to those of Ruby, including the + concatenation.
There is no char type- just length-1 strings.
Code:
string text = "I CAN HAZ CHEEZBURGER?";

Array (sub-type[[# of dimensions]])
Arrays are the most efficient storage type- however they can only hold numbers (of only one kind) and have a fixed size. Arrays can be multidimensional- indexed with multiple numbers within the brackets. Creation of arrays requires the "new" keyword. (e.g. [1,2,3] is a 3D array).
Code:
int[3] array_of_ints = new int[2,2,2] !-A 2x2x2 array of ints
array_of_ints =
[3, 4,
2, 1,
9, 0,
2, 5];
array_of_ints[1, 0, 0] = 24;

List (list[<type>])
Lists are similar to arrays, but have insert and remove operations and a dynamic size. Lists can be nested and are much less strict about type requirements, but are slower than arrays and take up more memory. [ ] literals define lists by default.
Code:
list object_list = [1,2,3];

Dictionary ((dict, dictionary)[<[key], [value]>]
Dictionaries can map one kind of object to another. You can associate things such as "monkey":"zoo" or 42:"the answer to life, the universe, and everything"
Code:
dict<str, str> websters = {"A": "The first letter in the english alphabet", "Aardvark": "an animal..."};

There are other built-in types, but they don't have any literals. Date, for instance.

I'm using Linux!

MPL Code Progress:
Starting on the VM. I need to define M-ASM.

Congratulations!
The game has been lost by you.
(But I still lost first.)

[Image: brawlx.png]

And then the Windows failed. -Emily Dickinson
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme:

Contact UsThe Developer's HomeReturn to TopReturn to ContentLite (Archive) ModeRSS Syndication