1. RE: namespace

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C227AF.F06BEC80
 charset=iso-8859-1

Hi Jiri,

> -----Original Message-----
> From: Jiri Babor [mailto:jbabor at PARADISE.NET.NZ]
> 
> 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 = 1
> 
>
> -- test.ex
> include test.e
> ? a
> constant a = 2
> ? a
> 
> 
> -- output
> 1
> 2
> 
> 
> Not even a simple warning about the previous instance! Is this 
> really desirable/acceptable behaviour?

I believe that RDS is considering issuing a warning whenever a declaration
overrides another one. However, which behaviour are you upset over - the
missing warning or the overriding?

I would like the overide functionality to continue. But I wonder if, when we
get the warning message facility, the programmer could code something like
...

  override constant a = 2

This would do two things: Skip the message being issued and alert the reader
of the code to the fact that the override is deliberate.


Another point, Jiri. The style of coding you demonstrate above, seems to say
that you knew that 'a' had been declared in test.e (thus the first "? a"
command). You then declare another 'a', knowing that the first one existed.
The problem for a code reader is then - is this second declaration a mistake
or deliberate? 

--------------
Derek.

==================================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en 
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht 
onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en 
de afzender direct te informeren door het bericht te retourneren. 
==================================================================
The information contained in this message may be confidential 
and is intended to be exclusively for the addressee. Should you 
receive this message unintentionally, please do not use the contents 
herein and notify the sender immediately by return e-mail.


==================================================================

------_=_NextPart_000_01C227AF.F06BEC80
Content-Type: application/ms-tnef

new topic     » topic index » view message » categorize

2. RE: namespace

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C227F3.D7A69530
 charset=iso-8859-1

> -----Original Message-----
> From: Jiri Babor [mailto:jbabor at PARADISE.NET.NZ]
> Subject: Re: namespace
> 
> 
> 
> Hi, Derek! You wrote:
> 
> >I believe that RDS is considering issuing a warning whenever 
> a declaration
> >overrides another one. However, which behaviour are you 
> upset over - the
> >missing warning or the overriding?
> >
> >I would like the overide functionality to continue. But I 
> wonder if, when we
> >get the warning message facility, the programmer could code 
> something like
> >...
> >
> >  override constant a = 2
> >
> >This would do two things: Skip the message being issued and 
> alert the reader
> >of the code to the fact that the override is deliberate.
> 
> I must admit I do not see your point in having this sort of 
> 'functionality'. If
> the 'constant' is no longer a constant, make it into a 
> variable and simply
> re-assign it.

It's not so much that a 'constant' is changing value, but more that somebody
is using the name I wanted to use. For example, if I use somebody's include
file that just happens to contain the line ...

  global constant True = 1, False = 0

but in my program I also want to use these names, and I don't care what that
somebody is using them for.

  constant True = ".T.", False = ".F."

This is were overriding is useful. Because I no longer have to be concerned
about the names that other people have chosen for identifiers.

> The behaviour is also inconsistent: for instance we are not 
> allowed to override
> user defined routines, where it would be, often, very useful.

You are very correct here. The same principle should apply - I shouldn't
have to worry about the names other people have chosen for identifiers, be
they variables, constants or routines.

However, a warning message would be nice to alert me to a possible mistake I
might be making.

> >Another point, Jiri. The style of coding you demonstrate 
> above, seems to say
> >that you knew that 'a' had been declared in test.e (thus the 
> first "? a"
> >command). You then declare another 'a', knowing that the 
> first one existed.
> >The problem for a code reader is then - is this second 
> declaration a mistake
> >or deliberate?
> 
> Sorry, Derek, that was just an illustration, simplified. In 
> actual case I am
> currently updating a large application with a number of 
> cascading includes,
> cutting and pasting, also using several versions. It just 
> happened I had the
> same constants (flags) declared at different levels with 
> slightly different
> values - and it took me two days to trace the bug...

Point taken.

----------
Derek.

==================================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en 
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht 
onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en 
de afzender direct te informeren door het bericht te retourneren. 
==================================================================
The information contained in this message may be confidential 
and is intended to be exclusively for the addressee. Should you 
receive this message unintentionally, please do not use the contents 
herein and notify the sender immediately by return e-mail.


==================================================================

------_=_NextPart_000_01C227F3.D7A69530
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

3. RE: namespace

-------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 message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu