1. Name-space proposal

Anybody:

If name-space worked in this way it would solve a lot of problems.

If a program contains a function foo()in the local main file and another

file is included containing a foo() function. The interpeter would not

stop but continue using the foo() function in the local main file.

When the program ends; the program would issue a warning that there

is a duplicate function foo() exists in include file xxx.e just

as it lists unused constants etc.

This would eliminate breaking code and allow debugging.

There could also be a special flag Example: with_out_name_space

to turn this on/off 

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan


Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » topic index » view message » categorize

2. Re: Name-space proposal

Bernie Ryan wrote:
> 
> Anybody:
> 
> If name-space worked in this way it would solve a lot of problems.
> 
> If a program contains a function foo()in the local main file and another
> file is included containing a foo() function. The interpeter would not
> stop but continue using the foo() function in the local main file.
> 
> When the program ends; the program would issue a warning that there
> is a duplicate function foo() exists in include file xxx.e just
> as it lists unused constants etc.
> 
> This would eliminate breaking code and allow debugging.
> There could also be a special flag Example: with_out_name_space
> to turn this on/off 

Except for the warnings, this sounds exactly like how it works now.
Here's how I tested this (maybe you can change it to cause the problem
you're having, since I suspect that it just wasn't clear what you meant):

file bar.ex:
--- begin file
include foo.e as Foo

global procedure foo(sequence foo)
	printf(1, "%s: bar.ex\n", {foo} )
end procedure

Foo:foo("foo")
foo("bar")
--- end file


file foo.e:
--- begin file
global procedure foo( sequence foo)
	printf(1, "%s: foo.e\n", {foo})
end procedure
--- end file


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

3. Re: Name-space proposal

Matt Lewis wrote:
> 
> Bernie Ryan wrote:
> > 
> > Anybody:
> > 
> > If name-space worked in this way it would solve a lot of problems.
> > 
> > If a program contains a function foo()in the local main file and another
> > file is included containing a foo() function. The interpeter would not
> > stop but continue using the foo() function in the local main file.
> > 
> > When the program ends; the program would issue a warning that there
> > is a duplicate function foo() exists in include file xxx.e just
> > as it lists unused constants etc.
> > 
> > This would eliminate breaking code and allow debugging.
> > There could also be a special flag Example: with_out_name_space
> > to turn this on/off 
> 
> Except for the warnings, this sounds exactly like how it works now.
> Here's how I tested this (maybe you can change it to cause the problem
> you're having, since I suspect that it just wasn't clear what you meant):
> 
> file bar.ex:
> }}}
<eucode>
> --- begin file
> include foo.e as Foo
> 
> global procedure foo(sequence foo)
> 	printf(1, "%s: bar.ex\n", {foo} )
> end procedure
> 
> Foo:foo("foo")
> foo("bar")
> --- end file
> </eucode>
{{{

> 
> file foo.e:
> }}}
<eucode>
> --- begin file
> global procedure foo( sequence foo)
> 	printf(1, "%s: foo.e\n", {foo})
> end procedure
> --- end file
> </eucode>
{{{


Matt:

   That is not what I mean:

   I write program with no name-space includes.

   I have a function called abs() in my program and I

   include some file that also has a function called abs()

   contained in it.

   The interpeter will abort giving an name-space error.

   I want the interpeter to just continue to run the program

   and report the error as warning when it exits.
 
   This way you don't have to keep starting/stopping to correct

   name-space errors or this would allow you to run a program

   using your own abs() function instead of another abs() in

   someone's include file.

   This would be like over-riding a function.      
 
Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

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

4. Re: Name-space proposal

Bernie Ryan wrote:
> Matt:
> 
>    That is not what I mean:
> 
>    I write program with no name-space includes.
> 
>    I have a function called abs() in my program and I
> 
>    include some file that also has a function called abs()
> 
>    contained in it.
> 
>    The interpeter will abort giving an name-space error.
> 
>    I want the interpeter to just continue to run the program
> 
>    and report the error as warning when it exits.
>  
>    This way you don't have to keep starting/stopping to correct
> 
>    name-space errors or this would allow you to run a program
> 
>    using your own abs() function instead of another abs() in
> 
>    someone's include file.
> 
>    This would be like over-riding a function.      
>  
> Bernie
> 
> My files in archive:
> WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>

I'm missing what you mean, Bernie.

Here, I tried the following code...
-- abs.e

global procedure abs()
    puts(1, "abs in abs.e\n")
end procedure

abs()

-- end file


-- ns-test2.ex

include abs.e

global procedure abs()
    puts(1, "abs in ns-test2.ex.\n")
end procedure

abs()

-- end file


and it worked without error.

I even went down one more level (created a file with abs that was included by
abs.e) and it still worked as expected.

In fact, the only way to get an error is to not override the function.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

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

5. Re: Name-space proposal

Bernie Ryan wrote:
> 
> Matt:
> 
>    That is not what I mean:
>
>    I write program with no name-space includes.
> 
>    I have a function called abs() in my program and I
>    include some file that also has a function called abs()
>    contained in it.
> 
>    The interpeter will abort giving an name-space error.
> 
>    I want the interpeter to just continue to run the program
>    and report the error as warning when it exits.
>  
>    This way you don't have to keep starting/stopping to correct
>    name-space errors or this would allow you to run a program
>    using your own abs() function instead of another abs() in
>    someone's include file.
> 
>    This would be like over-riding a function.      

I'm not sure I understand what you're asking for, exactly, or how the 
interpreter should deal with it.  Is it similar to what was discussed
in this thread?:

http://www.openeuphoria.org/cgi-bin/esearch.exu?thread=1&fromMonth=6&fromYear=8&toMonth=8&toYear=8&keywords=%22another+look+at+namespaces%22

In any case, please post a test case (read: actual code) that illustrates the 
issue, and describe how the interpreter should handle it.

Matt

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

6. Re: Name-space proposal

Matt Lewis wrote:

> 
> I'm not sure I understand what you're asking for, exactly, or how the 
> interpreter should deal with it.  Is it similar to what was discussed
> in this thread?:
> 
> <a
> href="http://www.openeuphoria.org/cgi-bin/esearch.exu?thread=1&fromMonth=6&fromYear=8&toMonth=8&toYear=8&keywords=%22another+look+at+namespaces%22">http://www.openeuphoria.org/cgi-bin/esearch.exu?thread=1&fromMonth=6&fromYear=8&toMonth=8&toYear=8&keywords=%22another+look+at+namespaces%22</a>
> 
> In any case, please post a test case (read: actual code) that illustrates the
> 
> issue, and describe how the interpreter should handle it.
> 

Matt:

Thanks Jason and Matt:



What version of the interper was this correction implemented in ? 

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

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

7. Re: Name-space proposal

Bernie Ryan wrote:
> 
> Matt Lewis wrote:
> 
> > 
> > I'm not sure I understand what you're asking for, exactly, or how the 
> > interpreter should deal with it.  Is it similar to what was discussed
> > in this thread?:
> > 
> > <a
> > href="http://www.openeuphoria.org/cgi-bin/esearch.exu?thread=1&fromMonth=6&fromYear=8&toMonth=8&toYear=8&keywords=%22another+look+at+namespaces%22">http://www.openeuphoria.org/cgi-bin/esearch.exu?thread=1&fromMonth=6&fromYear=8&toMonth=8&toYear=8&keywords=%22another+look+at+namespaces%22</a>
> > 
> > In any case, please post a test case (read: actual code) that illustrates
> > the
> > 
> > issue, and describe how the interpreter should handle it.
> > 
> 
> Matt:
> 
> Thanks Jason and Matt:
> 
> 
> What version of the interper was this correction implemented in ? 
> 
> Bernie
> 
> My files in archive:
> WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>

I don't think that Matt's improvement (discussed in the link above -- the
infamous alice-bob-chris-diane problem -- has been implemented. Unless Matt did
it in OOEU.

However I tested my code on Euphoria 3.1. I thought that it had always worked
that way.


--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

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

8. Re: Name-space proposal

Bernie Ryan wrote:
> 
> Matt Lewis wrote:
> 
> > 
> > I'm not sure I understand what you're asking for, exactly, or how the 
> > interpreter should deal with it.  Is it similar to what was discussed
> > in this thread?:
> > 
> >
> > http://www.openeuphoria.org/cgi-bin/esearch.exu?thread=1&fromMonth=6&fromYear=8&toMonth=8&toYear=8&keywords=%22another+look+at+namespaces%22
> > 
> > In any case, please post a test case (read: actual code) that illustrates
> > the
> > 
> > issue, and describe how the interpreter should handle it.
> > 
> 
> What version of the interper was this correction implemented in ? 
> 

It's not in an official release.  I did it with my version of the proprietary
source back in the day:

http://www.rapideuphoria.com/exm.zip

I'm just trying to make sure I understand what you're asking
about.  I find it too easy to get confused when talking in the abstract
about namespace issues, which is why I've asked about an example.

If your request is the same as discussed in the linked thread, then I
agree with this request, and we should add it to sf in the enhancement
requests (well, we should add it there in any case, IMHO).

Matt

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

9. Re: Name-space proposal

Matt Lewis wrote:
> 
> If your request is the same as discussed in the linked thread, then I
> agree with this request, and we should add it to sf in the enhancement
> requests (well, we should add it there in any case, IMHO).
> 
> Matt
Curious: how many people have actually been affected by how this works? I mean
in a way where the fix was not simple and where third-party code actually had to
be modified in order to work?

I know we've discussed it ad nauseum and I'm not about to argue for how things
should be. We all seem to have different ideas. I'm just interested in knowing
who has had problems related to namespacing/global pollution.

Matt: if this change gets included in the official distribution there should
also probably be a warning issued by the interpreter if possible.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

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

10. Re: Name-space proposal

this is a reasonable proposal, I back it. What is in the main file of a program
should have priority than what is in include in case of redefinition.

regards,
Jacques Deschênes


Bernie Ryan wrote:
> 
> 
> Anybody:
> 
> If name-space worked in this way it would solve a lot of problems.
> 
> If a program contains a function foo()in the local main file and another
> 
> file is included containing a foo() function. The interpeter would not
> 
> stop but continue using the foo() function in the local main file.
> 
> When the program ends; the program would issue a warning that there
> 
> is a duplicate function foo() exists in include file xxx.e just
> 
> as it lists unused constants etc.
> 
> This would eliminate breaking code and allow debugging.
> 
> There could also be a special flag Example: with_out_name_space
> 
> to turn this on/off 
> 
> Bernie
> 
> My files in archive:
> WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>
> 
> 
> Bernie
> 
> My files in archive:
> WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>

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

11. Re: Name-space proposal

jacques deschênes wrote:
> this is a reasonable proposal, I back it. What is in the main file of a
> program
> should have priority than what is in include in case of redefinition.

That's how it *does* work.

If a symbol is defined in the same file 
where the reference to it occurs, 
that symbol will be used, regardless of what
is defined in other included files. It has been that
way ever since 2.3 when the namespace feature 
was first introduced.

Bernie muist be using version 2.2 or earlier,
where namespaces didn't even exist.
 
> Bernie Ryan wrote:
> > 
> > Anybody:
> > 
> > If name-space worked in this way it would solve a lot of problems.
> > 
> > If a program contains a function foo()in the local main file and another
> > 
> > file is included containing a foo() function. The interpeter would not
> > 
> > stop but continue using the foo() function in the local main file.
> > 
> > When the program ends; the program would issue a warning that there
> > 
> > is a duplicate function foo() exists in include file xxx.e just
> > 
> > as it lists unused constants etc.
> > 
> > This would eliminate breaking code and allow debugging.
> > 
> > There could also be a special flag Example: with_out_name_space
> > 
> > to turn this on/off 
> > 
> > Bernie

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

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

12. Re: Name-space proposal

Hi Robert,
I tested it and that is true. I confounded that situation with this one:

--test.e
global constant test=123

--test2.e
global constant test=345

--main.ex
include test.e
include test2.e
? test

which result in this:
C:\Temp\main.ex:3
A namespace qualifier is needed to resolve test.
test is defined as a global symbol in:
    c:\temp\test.e
    c:\temp\test2.e



regards,
Jacques Deschênes

Robert Craig wrote:
> 
> jacques deschênes wrote:
> > this is a reasonable proposal, I back it. What is in the main file of a
> > program
> > should have priority than what is in include in case of redefinition.
> 
> That's how it *does* work.
> 
> If a symbol is defined in the same file 
> where the reference to it occurs, 
> that symbol will be used, regardless of what
> is defined in other included files. It has been that
> way ever since 2.3 when the namespace feature 
> was first introduced.
> 
> Bernie must be using version 2.2 or earlier,
> where namespaces didn't even exist.
>  
> > Bernie Ryan wrote:
> > > 
> > > Anybody:
> > > 
> > > If name-space worked in this way it would solve a lot of problems.
> > > 
> > > If a program contains a function foo()in the local main file and another
> > > 
> > > file is included containing a foo() function. The interpeter would not
> > > 
> > > stop but continue using the foo() function in the local main file.
> > > 
> > > When the program ends; the program would issue a warning that there
> > > 
> > > is a duplicate function foo() exists in include file xxx.e just
> > > 
> > > as it lists unused constants etc.
> > > 
> > > This would eliminate breaking code and allow debugging.
> > > 
> > > There could also be a special flag Example: with_out_name_space
> > > 
> > > to turn this on/off 
> > > 
> > > Bernie
> 
> Regards,
>    Rob Craig
>    Rapid Deployment Software
>    <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a>

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

13. Re: Name-space proposal

jacques deschênes wrote:
> 
> Hi Robert,
> I tested it and that is true. I confounded that situation with this one:
> 
> --test.e
> global constant test=123
> 
> --test2.e
> global constant test=345
> 
> --main.ex
> include test.e
> include test2.e
> ? test
> 
> which result in this:
> C:\Temp\main.ex:3
> A namespace qualifier is needed to resolve test.
> test is defined as a global symbol in:
>     c:\temp\test.e
>     c:\temp\test2.e
> 
> 
> regards,
> Jacques Deschênes
Situations like this is why namespaces were introduced in the first place. In 
this case, you *have* to use namespaces. Unfortunately, you have to use
namespaces for both variables, not just one or the other (which would be nice).

The problem lies when two third party libraries include the same symbol without
a namespace qualifier. Then you have to edit the libraries to fix it. That's why
libraries should definitely be using namespaces for subordinate includes.

I've got an idea that I want to try with the source, I'll get back to you on it.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

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

14. Re: Name-space proposal

Hi Jason,
namespaces could be improve by authorising named block inside files at
multi-level like this

namespace some_name
    code here
  namespace other_name
    code here
  end namespace -- other_name
end namespace  -- some_name

anything not defined as global should be private to its namespace
to access sublevel of namespaces one use a path like this:
some_name:other_name:global_indentifier

two new keywords should be added "namespace" and 
"filelocal" to extend the scope of an identifier outside its namespace to the
whole file.
so inside a namespace an identifier could be defined 3 ways:
1) object o -- private to its namespace
2) filelocal object o -- visible to the whole file.
3) global object o -- visible everywhere.

now we would have something like that

-- in math.e
namespace trigo
  global function htan(atom a) hyperbolic tangeant
    ...
  end function
  .
  .
  etc ...
end namespace

namespace matrix
  global function matrix_inv(sequence m) -- return the inverse of matrix m
     ...
  end function
end namespace

-- in main file
include math.e
? trigo:htan(45)
? matrix:matrix_inv(m)

the idea is borrowed from C#



regards,
Jacques Deschênes



Jason Gade wrote:
> 
> jacques deschênes wrote:
> > 
> > Hi Robert,
> > I tested it and that is true. I confounded that situation with this one:
> > 
> > --test.e
> > global constant test=123
> > 
> > --test2.e
> > global constant test=345
> > 
> > --main.ex
> > include test.e
> > include test2.e
> > ? test
> > 
> > which result in this:
> > C:\Temp\main.ex:3
> > A namespace qualifier is needed to resolve test.
> > test is defined as a global symbol in:
> >     c:\temp\test.e
> >     c:\temp\test2.e
> > 
> > 
> > regards,
> > Jacques Deschênes
> Situations like this is why namespaces were introduced in the first place. In
>  this case, you *have* to use namespaces. Unfortunately, you have to use
>  namespaces
> for both variables, not just one or the other (which would be nice).
> 
> The problem lies when two third party libraries include the same symbol
> without
> a namespace qualifier. Then you have to edit the libraries to fix it. That's
> why libraries should definitely be using namespaces for subordinate includes.
> 
> I've got an idea that I want to try with the source, I'll get back to you on
> it. 
> 
> --
> "Any programming problem can be solved by adding a level of indirection."
> --anonymous
> "Any performance problem can be solved by removing a level of indirection."
> --M. Haertel
> "Premature optimization is the root of all evil in programming."
> --C.A.R. Hoare
> j.

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

15. Re: Name-space proposal

Seems a bit too complicated to me, Jacques.

Variables now are either local to a routine or local to the file (if declared at
the top level). Or they are global when using the global keyword.

I have no problems with Euphoria's scope system. In fact, I think that it is
very simple and logical.

However, global symbols that are included with the include keyword are global no
matter at what level below they are included in. So I'm thinking of a different
way of doing things, but without breaking existing code.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu