Next: , Previous: Multiple Expressions, Up: Marsyas Expression Syntax Properties ( ie Real.pi or 'hello'.2 etc. )

Properties are simply a way of associating methods or values with types. As an example, the String module supports a number of methods that can accessed using the property notation. The expression String.len('hello') results in the natural value of 5. This expression could also be written as 'hello'.len() since the value 'hello' is known to be a string. This is just sugar for String.len('hello'). Here the first parameter to String.len is filled with the value. This can be used for variables of the right type as in s << 'hello', s.len() is similar to the previous except that variable s is defined.

All basic types or things that evaluate to basic types can respond to property calls. For example the conditional operator {?cond:expr1:expr2} evaluates to a single type so can take on a property as in {?true:'123':'12'}.len. To take this further a function call resulting in a basic type can take on properties as well and so on: '123'.len.max(4).