Function declarations

Function declarations give short names to XACML functions and declare their argument types so the compiler can perform type checking and type inference for operator overloading. System.alfa contains declarations for all the standard functions, so in most cases users do not need to declare any functions.

Here is an example of a function declaration:

function stringEqual = "urn:oasis:names:tc:xacml:1.0:function:string-equal"
     : string string -> boolean

The declaration consists of the short name, the full XACML identifier and the number and types of the arguments and the type of the return value.

The possible argument types are:

  • An atomic type that has been declared somewhere
    • Example: string
  • A bag of a type that has been declared somewhere
    • Example: bag[string]
  • Any atomic type
    • anyAtomic
  • A bag of any type
    • bag[anyAtomic]
  • Any atomic or bag type
    • anyAtomicOrBag
  • A function identifier reference
    • function

In addition, the last argument may be marked with a "*" to indicate that it may appear as a zero or any number of times.

Here is a more complex example of a function declaration:

function anyOf = "urn:oasis:names:tc:xacml:1.0:function:any-of"
     : function anyAtomic bag[anyAtomic] -> boolean

This defines the standard anyOf function from XACML 1.0. It takes three arguments, the first one being a function reference, the second any atomic value and the third any bag value. Use of this function could look like the following:

any-of(function[stringEquals], "doctor", Attributes.role)

Note that the type declaration is unable to express that for anyOf, as the argument types of the input function ("stringEquals") must match the types of the two other arguments. This limitation is there in order to keep the function declaration syntax reasonably simple.

Here is another example:

function anyOfAny3 = "urn:oasis:names:tc:xacml:3.0:function:any-of-any"
     : function anyAtomicOrBag anyAtomicOrBag* -> boolean

This is the XACML 3.0 generalized any-of-any function. It accepts a wider range of arguments than the 1.0 version. The first argument is a function reference and then there must be at least one more argument for any atomic or bag type.

The possible return value declarations are:

  • An atomic type that has been declared somewhere
    • Example: string
  • A bag of a type that has been declared somewhere
    • Example: bag[string]
  • Any atomic type
    • anyAtomic
  • A bag of any type
    • bag[anyAtomic]

Note that in contrast to the input arguments, the function reference and any atomic or bag type are not allowed.

Axiomatics
The Visual Studio Code extension for ALFA was developed by Axiomatics.
FOLLOW US