RE: namespace

new topic     » goto parent     » topic index » view thread      » older message » newer message

-------Phoenix-Boundary-07081998-

Hi Jiri Babor, you wrote on 7/9/02 4:41:17 PM:

>
>Strangely enough quite recently I tripped again over the following 
>aspect of the brave new world of 'improved' namespace handling:
>
>
>-- test.e 
>global constant a =3D 1
>
>
>-- test.ex
>include test.e
>=3F a
>constant a =3D 2
>=3F a
>
>
>-- output
>1
>2
>
>
>Not even a simple warning about the previous instance! Is this 
>really desirable/acceptable behaviour=3F

I think you have a point. A global constant should be both
global and constant! I have modified Bliss to enforce this, but
to allow duplicate definitions (many files can do 'global FALSE =3D 0').

Bliss now allows classes to have constants as members which
opens up some maybe useful namespacing techniques.

  class Windows_constants
      constant
      BN_KILLFOCUS =3D 7,
      BN_CLICKED =3D 0
      -- You could probably think of a few more!
  end class

Now the constants are only visible as member of the class:

   Windows_constants.BN_CLICKED
  
If thats too much typing:

   Windows_constants W   -- create an instance

   W.BTN_CLICKED    -- the instance also has the constants

The constants are neatly namespaced.
(Inheritance  and composition works also!)

Karl Bochert


-------Phoenix-Boundary-07081998---

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu