next up previous contents
Next: Bibliography Up: Dollar Bracket Expressions Previous: Vector and String Subscription   Contents

Macro Calls

Any string stored in a variable can serve as a macro, so there is no need to have a macro-definition operator. The pure strings using the ${: }-operator come handy, though, since they allow to define dollar bracket expressions that are not directly parsed. Strings are parsed with the ${! }-operator. Defining

x2  = ${: ${* ${x} ${x}}}
x4  = ${: ${* ${!x2} ${!x2}}}
x6  = ${: ${* ${!x4} ${!x2}}}
sin = ${: ${* ${x} 
               ${+ 1       
                   ${/ ${!x2} -6}  
                   ${/ ${!x4} 120}   
                   ${/ ${!x6} -5040}
makes it possible to compute sinuses inside a GetPot file, for example
x = 0.212   
info = ${!sin}
will assign something that is close to the sinus of 0.212 to the variable info. Keep in mind, that through the huge amount of float-string conversions, back and forth, a lot of precision is lost. Don't consider this as a disadvantage ! As said before, configuration files are not there to write programs. A configuration file language, therefore, has to be a bit cumbersome, in order to prevent mayhem.

Frank-Rene Schaefer 2002-09-14