1. Michael Tindal
  2. Silver


Silver /

Filename Size Date modified Message
217 B
259 B
276.5 KB
3.4 KB
963 B
163 B
743 B
145 B
443 B
10.8 KB
1.6 KB
7.7 KB
Silver is a new scripting language based on C-family style of languages.  It is built on top of the Objective-C runtime and offers bi-directional
interopability between itself and Objective-C with support for C libraries via the use of BridgeSupport.

Silver's main purpose is to provide scriptability to KittyMUD and associated MUDs, but has grown to be a fully featured scripting language.

Silver is an object-oriented language with facilities for regular expression matching, ruby style blocks, and interopability with the Objective-C runtime.

Silver is a scripting language with a syntax similar to Objective-C with heavy influence from Ruby.  With the exception of low-level things like direct
pointer manipulation and protocol definition, anything you can do in Objective-C you can do in SV.

Consider the following Objective-C Code:

@interface SVTestClass {
	NSNumber* a;
	NSNumber* b;




The corresponding SV script would look like:

class SVTestClass {

    def init { ... }

    def doSomethingWithNum(num) { ... }

Silver has block syntax similar to the syntax found in Ruby:

func(x) { for(i in x) { yield i; }; }; func(7) { |o| o += 2; };

func(x,&f) { for(i in x) { f(x); }; }; func(y) { |o| o += 2; };

In addition, you can define anonymous functions using the form ->(args) { ... }

Arrays can have objects added to them using the << operator.

a = []; /* same as a = NSMutableArray.array; */ a << 2;

The operator can be nested:

a << 2 << 3 will give you an array of [2,3].

The empty dictionary is {}.  This is equivalent to [NSMutableDictionary dictionary].
Dictionaries have the form { 'key0' => value, 'key1' => value }.

You can use : followed by a string or identifier to create a symbol like in Ruby.  In silver symbols are unique.
Like Ruby, our symbols implement the to_s and to_i functions for converting to a true string or number.

All variables in Silver are objects, and all objects in Silver descend from NSObject.  Classes defined in Silver descend from NSObject unless otherwise
declared. Silver implements a category on NSObject to implement dynamic ivars. The silver runtime boxes/unboxes objects to and from C/Objective-C as needed, including
pointers, blocks, and methods.

Exceptions in silver are handled in the same fasion as Ruby, except we use C-style braces:
begin { ... } rescue ex => var { ... } else { ... } ensure { ... }

You can catch more than one exception type by separating them with a comma.  The variable name given will have the thrown exception object stored, if you do not
pass a variable you can access the exception object using $#.

Documentation for the language's syntax and some more utility classes are planned for the future, but in the meantime, take a look in the scripts/
directory, particulary the *_tests.sv files, or svunit.sv, and the unit tests to get a sense of how the language works.

Portions of silver are Copyright (C) Tim Burks and Philip White.  Used under the terms of the Apache License 2.0.  See license.apache for more information.
MABlockClosure.m and MABlockClosure.h are Copyright (C) Mike Ash.  Used under the terms of a BSD-like license.  See license.bsd for more information.
Silver (C) 2011 Michael Tindal.  Use is governed by the Lesser General Public License 3.0,  See license.lgpl for more information.