swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
    Related Concepts  
operator  

~ (identity)

 

 

Return type: The same as the type of its argument
Returns:       

The value of the expression



Syntax
  ~ expression


Purpose

You can use the identity operator (~) to force an expression contained in a pattern to be evaluated so that the result of the expression becomes part of the pattern. This is only necessary for expressions which are ambiguous in their syntax, so that OmniMark cannot tell, without the identity operator, whether the expression is a value expression to be evaluated or a sequence of pattern expressions.

The identity operator is required in the following cases:

You must use the identity operator when using an item on a shelf in a pattern:

  ~foo[2]
  ~foo{"bar"}

You must use the identity operator when calling an infix function (one in which the function name is placed between its arguments):

  ~("d" % foo)
  ~(foo take (any** ","))

You can also use the identity operator in place of the keyword when to add a conditional expression to a pattern. Thus you can replace:

  (when title="")
with
  ~(title="")

      Related Concepts
   Pattern matching
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACYLIBRARIES ] [ ERRORS ]

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:44:55 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.