One of the biggest problems in creating the BlobbieScript engine
was to try and add in real language support while adding the
flexibility of evaluating expressions as can be done in almost any
other programming language. To maximize ease and backward
compatibility there exist two modes of expression evaluation: pure and
impure.
Pure expressions are any expressions that are part of a block
control expression or part of a function's parameter part. These are
called pure because they do not require special treatment to be
evaluated in their context. To illustrate, the following is now
possible:
0001 if( %getLevel( $n ) < 50 and !%getRandom( 1, 10 ) )
0002 {
0003 damage $n %( (1d10 + 1) * 3 )
0004 }
0005 else-
0006 if( %getAlign( $n ) / 10 > 60 or %getAlign( $n ) < -60 )
0007 {
0008 damage $n %( 1d(1d10) )
0009 }
0010 endif
The difference between pure and impure expressions is also
illustrated above. Notice to get the power of expression evaluation
within a non- block control statement the expression needs to be
evaluated with the special %() function. This is because for backward
compatibility reasons the new engine guesses that anything in a block
control statement is any of variable, function, or string. Given this
interpretation all tokens extracted are considered to be implicitly
joined by an invisible concatenation operator. Since this may become
confusing if a variable is used that blends into an actual word the
following can be used to ensure the end of the variable:
0001 @name = %getName( $n )
0002 echoto r all @{name}'s mother is a wench!
The advantage of such expression evaluation is that it gets rid of
the old system of $.calc( 1, +, 3 ) since this can be expressed as %(
1 + 3 ). Moreover the engine fully supports integers, floats, strings,
and associative arrays (AKA: dictionary, string indexed array,
hash). |