Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #90 Read-only outside

Expose a read-only integer x to the outside world while being writable inside a structure or a class Foo.

package Foos is
      
   type Foo is private;
      
   function X (Self : Foo) return Integer;
      
private
   type Foo is
      record
         X : Integer;
      end record;
      
end Foos;
   
package body Foos is
      
   function X (Self : Foo) return Integer is (Self.X);
      
end Foos;

New implementation...
< >
bbtemp