1. Re: Namespace improvement ?

Verne Tice wrote:

> Chris Bensler wrote:

<snip>

>> Realistically, it would break most everybody's code.
>> However, the transition would be very minor (change all cases of
>> "include foo" to "global include foo").

Yes, very minor. And this replacement can be done automatically by a
small program. I hereby volunteer to write such a program, in case that
the suggested change to the scope of 'include' will be made.

>> I deal with worse scenarios,
>> just trying to rectify the mess that namespacing makes.
>
> Then,
>
> If you don't want to break existing code (or future code based on today's
> rules
> why not make the change:
>
> "local include foo" to make foo's globals actually local to the including
> file?

This is only the second best solution.

> This would simply require that the new behavior be invoked explicity.

This would be inelegant, inconsistent, and potentially confusing for
newbies.

It is good programming practice (because it makes debugging easier, and
reduces maintainace costs) to keep the scope of symbols as small as
possible. That means in this context, that the smaller scope (local)
should be used by default, and the global scope only should be used,
when the programmer *explicitely* wants to do so. This is currently
already the case with constants, variables, and routines:

       aequence foo
global aequence foo

       funtion foo()
global funtion foo()

etc.
So *of course* it has to be

       include foo.e
global include foo.e


In 'refman_2.htm' that ships with Euphoria 2.5 beta, it reads
(2.4.2 Scope):
"Euphoria encourages you to restrict the scope of symbols."
Unfortunately, this encouragement is currently not as consequent
and powerful as it could/should be.

Regards,
   Juergen

-- 
Have you read a good program lately?

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu