[Home]AphroditeDescription

TheSourcery | RecentChanges | Preferences | Index | RSS

Difference (from prior minor revision) (no other diffs)

Changed: 1c1,102
Describe the new page here.
This is from a post describing some of the features of my mudlib language, Aphrodite.

Aphrodite Description




Below is a decompiled object dump with many attributes and methods expunged and a few added for illustration that wouldn't be there. Note that the programmer normally doesn't type all this in all at once, as defining objects, attributes and methods is done interactively online. The begin and end keywords common to pascal are rarely inserted manually by the programmer unless they are specifically coding a sub block within a method. I used to have pascal like blocks in all my if/else statements and loops but now they are instead marked with their own special terminators, e.g. endif/wend/endfor/until.

There's a lot of implicit stuff here that might not be obvious.

* All local variables (inside methods) and global attributes (object data) are variants. They can be object references themselves, integers, fixed-point decimal, strings, lists, and associative arrays. The precision of fixed point variants is determined by the initial assign, from then on they remain at that precision even when assigned to by integers and other precision fixed-points. That's true of integer variants as well.
* Lists can be defined inline using braces and are nestable, e.g. var listostuff := {"axe", 3, 98.6, {"handle", "grip", 42}, 65}. Associative arrays also can be defined inline using bracketed pairs and are also nestable, e.g. var weighttable := [["bag",10.00],["sword",55.50]]. Strings are delimited in double quotes, in case that don't show in the sample. All can be subscripted using any type inside brackets []. It's contextually unambiguous although it may not seem so at first. Both lists and a-arrays are implicitly heterogeneous as they can stored any variant.
* All inheritance is private. Inheritance is MI and runtime dynamic. The issues of diamonds of death, and recursive inheritance are solved. Recursion via search and mark and diamonds are allowed as the ancestor search is a pre-defined search order, breadth-first left to right. The the ancestor of all things is $object and like Java it never need be explicit .
* Accessor modifiers on methods can be exported(public inheritance), reserved(public and nonoverideable), and native(implemented in the driver).
* There are a number of predefined variables available in the context of execution. Most of them have handy perl-like shortcuts as well as long names. Arguments are always passed by a variant list. args(_@), nothing(_!), user(_&), and this(_#) are used below. The meaning of 'nothing' depends on the variant type, it could mean empty, unassigned, or 0.
* Object references are preceded by dollar signs. Object names are created explicitly and can be constructed using methods in any ancestor. There are no vnums nor any way to access the internal object id numbers, yet they are present.
* All errors are predefined exceptions which are catchable. I have no user type exceptions yet.
* The loop constructs are foreach/endfor, repeat/until and while/wend. I have no C-like for loop.
* Dot operator is traditional C++ semantics. Comments are C/C++ style but must be inside blocks.

Here's some sample code:


object $bag
begin;
inherits $container, $thing;
attrib weight 50.00;
attrib maxweight 1000.00;
attrib contents {};
attrib location $user_tyche;

method weight reserved
begin;
if _@
// test for arguments
weight := weight + _@[1];
endif
return weight;
end;

method get exported
begin;
var item;

item := _#.getenv(_@[1]);
// getenv inherited from container
if item = _!
_&.tell("There is no %n inside %n, item, name)
return "There is no " + _@[1] + " inside.";
else
_#.weight(item.weight() * -1);
item.moveto(_&);
_&.location().tell("%n removes %n from %n.", _&, item, name);
endif
end;

method fastroutine native

method sample_loops exported
begin;
// prints hello world to user.
var msg, i;
msg = {"Hello", "world"};

i := 1;
repeat
_&.tell(msg[i]);
++i;
// no postfix operator
until i = 3

foreach x in msg
_&.tell(x);
endfor

i := 1;
while i < 4
_&.tell(msg[i]);
i := i + 1;
wend
end;

method sample_lookup exported
begin;
var table, item;

table := [[1,"orc"],
[2,"elf"],
[3,"dwarf"]
];
if args
item := table.lookup(args[1]);
if item
user.tell("%v found", item)
else
user.tell("Couldn't find a match for %v", args[1]);
endif
else
user.tell("No arguments provided");
endif
end;




This is from a post describing some of the features of my mudlib language, Aphrodite.

Aphrodite Description

Below is a decompiled object dump with many attributes and methods expunged and a few added for illustration that wouldn't be there. Note that the programmer normally doesn't type all this in all at once, as defining objects, attributes and methods is done interactively online. The begin and end keywords common to pascal are rarely inserted manually by the programmer unless they are specifically coding a sub block within a method. I used to have pascal like blocks in all my if/else statements and loops but now they are instead marked with their own special terminators, e.g. endif/wend/endfor/until.

There's a lot of implicit stuff here that might not be obvious.

Here's some sample code:

object $bag
begin;
inherits $container, $thing;
attrib weight 50.00; 
attrib maxweight 1000.00;
attrib contents {};
attrib location $user_tyche;

method weight reserved
begin;  
  if _@ 
    // test for arguments
    weight := weight + _@[1];
  endif
  return weight;
end;

method get exported
begin;
  var item;
  
  item := _#.getenv(_@[1]); 
  // getenv inherited from container
  if item = _!
    _&.tell("There is no %n inside %n, item, name) 
    return "There is no " + _@[1] + " inside.";
  else  
    _#.weight(item.weight() * -1);
    item.moveto(_&);
    _&.location().tell("%n removes %n from %n.", _&, item, name); 
  endif  
end;    

method fastroutine native

method sample_loops exported
begin;
  // prints hello world to user.
  var msg, i;
  msg = {"Hello", "world"};
  
  i := 1;
  repeat
    _&.tell(msg[i]);
    ++i;  
    // no postfix operator
  until i = 3
  
  foreach x in msg
    _&.tell(x);
  endfor
  
  i := 1;
  while i < 4
    _&.tell(msg[i]);
    i := i + 1; 
  wend
end;  

method sample_lookup exported
begin;
  var table, item;
  
  table := [[1,"orc"],
            [2,"elf"],
            [3,"dwarf"]
           ];
  if args
    item := table.lookup(args[1]);
    if item
      user.tell("%v found", item)
    else
      user.tell("Couldn't find a match for %v", args[1]);  
    endif  
  else
    user.tell("No arguments provided");
  endif
end;


TheSourcery | RecentChanges | Preferences | Index | RSS
Edit text of this page | View other revisions
Last edited May 28, 2005 7:31 am by JonLambert (diff)
Search:
All material on this Wiki is the property of the contributing authors.
©2004-2006 by the contributing authors.
Ideas, requests, problems regarding this site? Send feedback.