Web Polygraph 

    Reference Manual
·         Statements
             Code Blocks
       Simulation models
       Command options
       User-defined distr
       Loadable modules
    User Manual


    Wish List
    Mailing List

    Other Tools


Home · Search · Print · Help 


PGL code is a sequence of statements separated by semicolumns. There are three major kinds of statements: ``expression statements'', ``declaration statement'', and ``code blocks''. All are described below.

1. Expression Statement

There are two kinds of expression statements: ``assignments'' and function or procedure ``calls''. All have syntax common to procedural languages.

bar.field1 = 1235;
foo = bar;
f(foo, bar);
z = normal(10sec, 3sec);

When many field modifications to the same object are required, it is often convenient to use a scope operator. The two pieces of code below are equivalent.

foo.field1 = 1;
foo.field2 = "something";
foo.field3 = '';

// same using foo's scope
foo = {
    field1 = 1;
    field2 = "something";
    field3 = '';

PGL uses the same rules for scoped statements as for the statements inside a code block (see below). For example, you can declare new [local] variables inside a scope operator.

2. Declaration Statements

These are no different from declarations in C and many other languages. All declarations start with the object type and may have an optional initialization clause. Just remember that every object in PGL must be declared exactly once and before first use.

int i;
string s = "something";
rate peak_rate = 140/sec;
addr[] hosts = '10.13.0-4.1-250';

Bench TheBench = {
    client_side.addr_mask = 'fxp0::';
    server_side.max_host_load = peak_rate;

3. Code Blocks

Sometimes it is convenient to group several statements into a ``block''.

// do magical calculations
    int foo = 12345;
    int bar = foo / clientHostCount(TheBench);
int foo = 0; // this is a different foo

As the above example illustrates, variables declared inside a block are local to that block.

Home · Search · Print · Help