FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Namespace definition

A namespace denotes a group of identifiers in a program that is distinguished by a common name (prefix). A fully qualified entity name in Mosel is of the form nspc~ident where nspc is a namespace name and ident an identifier in the namespace. The use of namespaces can help structure data when working with multiple packages.

Further explanation of this example: 'Mosel User Guide', Chapter 16 Packages

Source Files


   Mosel Testing Examples

   file mynspkg1.mos 
   Testing namespaces
   - main model: mynstest.mos -
   (c) 2018 Fair Isaac Corporation
       author: S. Heipcke, 15 May 2018

package mynspkg1
 namespace ns1, ns3, ns3~ns31         ! This package defines 3 namespaces:
 nsgroup ns1: "mynspkg2"              !  * ns1 + ns3~ns31 restricted to pkg2
 nsgroup ns3~ns31: "mynspkg2"         !  * ns3 is visible to all
 nssearch ns1                         ! 'ns1' can be used without prefix

   ns3~R = 1..10
   ns1~Ar: array(ns3~R) of integer    ! Index set in different namespace
   vi, ns3~vi, ns3~ns31~vi: integer   ! 3 different entities

 public declarations
   vp: integer

 procedure ns1~proc1(val:integer)     ! Subroutine in a namespace
   ns3~vi:=val; ns3~ns31~vi:=2*val; vi:=val; vp:=val
   Ar(5):=val                         ! No prefix: 'ns1' is in search list
   writeln(" In ns1~proc1: ", vi)

 public procedure proc2(val:integer)  ! Public subroutine
   writeln(" In proc2: ", val)

 procedure proc3(val:integer)         ! Private subroutine
   writeln(" In proc3: ", val)

Back to examples browserPrevious exampleNext example