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

Namespace definition

Description
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
By clicking on a file name, a preview is opened at the bottom of this page.
mynspkg1.mos[download]
mynspkg2.mos[download]
myns_test.mos[download]





mynspkg2.mos

(!******************************************************
   Mosel Example Problems
   ======================

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

package mynspkg2
 uses 'mynspkg1'
 namespace ns3~ns31                   ! Namespace used in this package
 nssearch ns1                         ! 'ns1' can be used without prefix

 public procedure frompkg2(val: integer)
   proc1(val)                         ! Procedure in namespace 'ns1'
   writeln("  frompkg2:",ns3~ns31~vi) ! Namespace 'ns3~ns31' is not searched
!   writeln("  vi=", vi)              ! This fails: private symbol of pkg1
   writeln("  vp=", vp)               ! Public symbol of pkg1
   writeln("  Ar(5)=", Ar(5))         ! Contained in 'ns1' (prefix optional)
 end-procedure
end-package


Back to examples browserPrevious exampleNext example