Strict Types In Expressions

Expressions can auto-convert types or strictly honour data types

Automatic Type Conversion

By default, any arithmetic expression on values that look like numbers will proceed to treat those values as numbers even if their underlying data type is not numeric. This can be illustrated with the following example:

» 1 + "2"
3

This is useful because shell processing is generally operating on bytes, which often are treated as strings. Thus the OS doesn’t have any concept of a numeric verses non-numeric parameter. As far as Linux or Windows knows, all numbers are strings too. So having Murex auto-convert values reduces your day-to-day cognitive overhead when working in the shell.

Strictly Honouring Type Annotations

Sometimes you might be writing Murex-native code and that code needs to care about type safety. For example, you might need the leading zeros retained in string when making comparisons. In situations like this, you can enable strict types via config:

config set proc strict-types true

Using the same example from the previous section but with strict-types set to true:

» 1 + "2"
Error in `expr` (0,1): cannot Add with string types
                     > Expression: 1 + "2"
                     >           :     ^
                     > Character : 5
                     > Symbol    : QuoteDouble
                     > Value     : '2'

Scope

strict-types will be scoped to that function and thus changing this option will not cause accidental side-effects in other functions.

See Also


This document was generated from gen/user-guide/strict-types_doc.yaml.

This site's content is rebuilt automatically from murex's source code after each merge to the master branch. Downloadable murex binaries are also built with the website.

Last built on Thu Aug 15 14:38:34 UTC 2024 against commit 50ed9d650ed9d6df391240d3c2c02e623636e508dfcdad1.

Current version is 6.2.4000 which has been verified against tests cases.