Show Changes Show Changes
Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Rename Rename
Administration Page Administration Page
Search

History

4/25/2007 9:51:15 PM
-202.82.130.33
4/25/2007 9:50:24 PM
-202.82.130.33
2/24/2006 11:22:42 PM
-63.231.53.241
2/24/2006 11:17:19 PM
-63.231.53.241
9/16/2005 5:58:11 AM
-131.107.0.104
List all versions List all versions

RSS feed for the FlexWiki namespace

Wiki Talk Member
.
Summary
A WikiTalk member is either a property or a method of an object

Overview

WikiTalk members are similar to members in .NET programming language as well as many other object-oriented languages.

Members can be either properties or methods. The only difference is whether they take parameters; properties don't and methods do.

Methods and Arguments

Basic method Arguments

Methods "take" arguments. Consider, for example, this use of the Substring method:

 "hello".Substring(1,3)

The Substring method extracts a substring from another string. It takes two arguments (both integers). The first argument is the zero-relative index of the first character you want to extract and the second the number of characters you want to extract.

Arguments can be arbitrarily-complex expressions, so the following is valid:

 "hello".Substring(1,"dogfood".SubString(0,3).Reverse.Length)

This expression will produce the same result as the previous one (i.e., the string "ell"). It'll get there in a more round-about way, though First it takes the seven-character string "dogfood". Then it takes the substring from that that starts at index 0 and continues for three characters: "dog". It then reverses this string (producing "god") and then takes the length of that (producing 3).

Optional Arguments

Some methods allow for optional arguments. For example, the Substring method on strings allows you to leave off the second argument (the number of characters you want). In cases where a method allows for optional arguments, all of the optional arguments are stacked up at the end of the list of arguments.

Variable Numbers of Arguments

Some methods allow for a variable number of arguments. For example, the InterWikiBehavior takes a few required arguments followed by an unlimited number of additional (optional) arguments. In cases where a method allows for a variable number of arguments, all of the optional variable arguments are stacked up at the end of the list of arguments.

Block Arguments

One of the most powerful elements of WikiTalk is the WikiTalkBlock. A Block is a chunk of WikiTalk that can do something and can be treated as a first-class object in the language. For example, consider this WikiTalk:

 ["hello", "dogfood", "cat"].Collect
 { each |
        each.Length
 }

This will produce an Array of three numbers (5, 7 and 3 -- the lengths of the three strings). The block being used here is:

 { each |
        each.Length
 }

Blocks are delineated by curly-braces ({ and }). Unlike many program languages that treat blocks as a special syntactic element, WikiTalk treats them as object -- just like everything else. There's a bit of syntactic sugar that allows you to use blocks in a way that feels naturals, but they're really just more objects.

To be clear about this, look at this rewitten version of the WikiTalk above:

 ["hello", "dogfood", "cat"].Collect({ each | each.Length})

The interesting thing about this is that the block appears as an argument of the Collect method. In fact, this is how WikiTalk really handle things: you can specify a block either way. In the WikiTalk interpreter, the Collect() method takes a Block as an argument. When you write WikiTalk, you can specify the block either way.

To generalize, the following two forms of WikiTalk are absolutely identical in meaning and behavior:

 function(arg1, arg2, {some block here})

and

 function(arg1, arg2)
 {
   some block here
 }

This principle applies across any function that takes a block as an argument. For example:

 topic.LastModifiedBy.IfNull
 {
         "I have no idea who modified this topic last"
 }

is identical to:

 topic.LastModifiedBy.IfNull( {
         "I have no idea who modified this topic last"
 } )

To complete the picture, let's look at a further example:

 topic.LastModifiedBy.IfNull
 {
         "I have no idea who modified this topic last"
 }
 Else
 {
        "Ah ha!  I know who modified this; do something different"
 }

This is actualy an invocation of a method called IfNullElse with two arguments (each a block). This way to specify more than one block as an argument carries generall through the WikiTalk language. While there aren't any examples of it yet, you could have ten blocks (with 9 intervening keywords). All the keywords would be slammed together to make the full name of the method and the blocks woul dbe passed along as arguments.

WikiTalkTodo

It would be handy if a property containing an appropriately defined block could be used in place of a block in argument lists.

For example, if we defined the property FooTopic:

FooTopic

Then we could collect these pages as follows:

  allTopics.Collect(FooTopic)

Workaround

You can get around this by enclosing the property function call in a block. Here's an example:

Numbers
AddOne
AsInteger
XForm
1 2 3 101 1001

-- JimmySieben [2005-09-11]

Not logged in. Log in

Welcome to the home of FlexWiki, an experimental collaboration tool, based on WikiWiki.

This is FlexWiki, an open source wiki engine.

This site supports the new NoFollow anti-spam initiative.
Change Style

Recent Topics