1. Conflict add_item
- Posted by unsteady Mar 06, 2015
- 1649 views
add_item is a function in sequence.e
add_item is also a function in wxeud.e I was working away happily and added
include sequence.e in my work and it crashed saying add_item not found.
For myself, rather than change anything in sequence.e, I have made changes as follows in wxeud.e
public procedure add_items( atom list, sequence text )-- new public procedure with an "s" added to "add_item" add_item( list, text ) end procedure procedure add_item( atom list, sequence text ) -- not a public procedure any more c_proc( WX_ADD_ITEM, {list, text} ) end procedure
This works for me and I use add_items. However, sequence.e is long established, so you can't change it there.
wxWidgets is long established and you can't change the .dll to suit you , so i don't know what permanent change you would want to make for the wxEuphoria users.
2. Re: Conflict add_item
- Posted by evanmars Mar 06, 2015
- 1642 views
Use namespaces?
include wxeu/wxeud.e as wx include std/sequence.e as seq sequence s = {66,67,68} puts(1,s & '\n') s = seq:add_item(65,s) puts(1,s & '\n')
ouput:
BCD ABCD
3. Re: Conflict add_item
- Posted by unsteady Mar 06, 2015
- 1678 views
Thanks.
I will try it and post again - probably after 6 hours.
4. Re: Conflict add_item
- Posted by unsteady Mar 06, 2015
- 1634 views
Use namespaces?
include wxeu/wxeud.e as wx include std/sequence.e as seq sequence s = {66,67,68} puts(1,s & '\n') s = seq:add_item(65,s) puts(1,s & '\n')
ouput:
BCD ABCD
evanmars:
I tried your suggestion but it still comes with error during interpretation.
5. Re: Conflict add_item
- Posted by evanmars Mar 06, 2015
- 1647 views
Can you post the exact error message you are getting?
6. Re: Conflict add_item
- Posted by unsteady Mar 07, 2015
- 1578 views
Can you post the exact error message you are getting?
include “wxeud.e" as wx include "SysVecN15.ex" include "SysDefN15.ex" include "sequence.e" as seq include "convert.e" without warning -- I try to bring all my includes in the same work area as the main program. -- There is some code here. The relevant code is as below. for i=1 to 12 do -- for i=1 to 4 do ComboList=ListSz[i] ListText=MainAll[i] for j = 1 to ComboList do -- for j = 1 to 3 MainItem= ListText[j] add_item( MainBox[i], MainItem ) end for mIndex = 1 -- default start value MainItem = sprintf("%d", mIndex) show_window( MainBox[i] , wxTrue ) end for
You can see from the commented loop lines above that I tried to reduce the two loops in case there was situation related to a particular item.
Error message appears in a small console window as follows:-
C:\euphoria\Work\Menu_Combo_Test15c.exw:100 <0074>:: Errors resolving the following reference: Menu_Combo_Test15c.exw:<100>: add_item add_item< Mainbox[ i ], Mainitem > Press Enter
7. Re: Conflict add_item
- Posted by ne1uno Mar 07, 2015
- 1600 views
Can you post the exact error message you are getting?
include “wxeud.e" as wx include "SysVecN15.ex" include "SysDefN15.ex" include "sequence.e" as seq include "convert.e" without warning -- I try to bring all my includes in the same work area as the main program. -- There is some code here. The relevant code is as below. for i=1 to 12 do -- for i=1 to 4 do ComboList=ListSz[i] ListText=MainAll[i] for j = 1 to ComboList do -- for j = 1 to 3 MainItem= ListText[j] add_item( MainBox[i], MainItem ) end for mIndex = 1 -- default start value MainItem = sprintf("%d", mIndex) show_window( MainBox[i] , wxTrue ) end for
You can see from the commented loop lines above that I tried to reduce the two loops in case there was situation related to a particular item.
Error message appears in a small console window as follows:-
C:\euphoria\Work\Menu_Combo_Test15c.exw:100 <0074>:: Errors resolving the following reference: Menu_Combo_Test15c.exw:<100>: add_item add_item< Mainbox[ i ], Mainitem > Press Enter
include "std/sequence.e" as seq
8. Re: Conflict add_item
- Posted by evanmars Mar 07, 2015
- 1623 views
use the namespace for the function:
seq:add_item( MainBox[i], MainItem )
9. Re: Conflict add_item
- Posted by jimcbrown (admin) Mar 07, 2015
- 1558 views
use the namespace for the function:
seq:add_item( MainBox[i], MainItem )
Shouldn't it be the other way around?
wx:add_item( MainBox[i], MainItem )
10. Re: Conflict add_item
- Posted by unsteady Mar 07, 2015
- 1581 views
use the namespace for the function:
seq:add_item( MainBox[i], MainItem )
seq:add_item( MainBox[i], MainItem ) -- This works creating the boxes but does not fill them with the items wx:add_item( MainBox[i], MainItem ) -- This works creating the boxes and fills with items properly, the same way as my own change in wxeud.e -- where I removed the public assignment of the procedure and created a new public procedure on top of it with the name add_items with an "s"
However, I only use sequence.e for other reasons, and don't use the add_item of sequence.e so for me the best solution is to keep wxeud.e unchanged, and comment out the add_item in sequence.e
If and when I want to use the add_item of sequence.e I will figure out the use probably with another name given to it.
To continue using wx:add_item, I would have to go through a lot of work I have done in the past 2-3 months and change everywhere. I suppose I can use the software which goes through a lot of files doing "Search and Replace" but right now I will leave it as that for myself.
I hope this has helped others who want to use such conflicting names.
Thanks for your time and trouble.
11. Re: Conflict add_item
- Posted by mattlewis (admin) Mar 08, 2015
- 1589 views
However, I only use sequence.e for other reasons, and don't use the add_item of sequence.e so for me the best solution is to keep wxeud.e unchanged, and comment out the add_item in sequence.e
The namespace system is designed to allow programmers to solve these issues without having to edit third party libraries. For the purpose here, it's not important what any particular programmer does. The recommended way of doing things is to add namespace qualifiers in your code when you run into this sort of problem.
Editing the libraries like that is going to cause you problems.
Matt
12. Re: Conflict add_item
- Posted by jimcbrown (admin) Mar 08, 2015
- 1558 views
However, I only use sequence.e for other reasons, and don't use the add_item of sequence.e so for me the best solution is to keep wxeud.e unchanged, and comment out the add_item in sequence.e
The namespace system is designed to allow programmers to solve these issues without having to edit third party libraries. For the purpose here, it's not important what any particular programmer does. The recommended way of doing things is to add namespace qualifiers in your code when you run into this sort of problem.
Editing the libraries like that is going to cause you problems.
Well, I can see it from the OP's POV. Having used add_item() from wxEuphoria in hundreded or thousands of places in a very large file, then suddenly needing to include std/sequence.e for one function call that's only used in one place, resulting in the need to manually edit hundreds or thousands of lines of text (just to ad the "wx:" bit) is annoying. A modern text editor should have no problems changing all such references at once - but editing std/sequence.e directly results in fewer lines to audit I suppose.
Perhaps we need a way to say "if a namespace conflict exists, instead of throwing an error to warn the programmer, just default to using this namespace and require all calls to the other namespace in this file to be explicitly qualified" or something.
13. Re: Conflict add_item
- Posted by mattlewis (admin) Mar 09, 2015
- 1596 views
Editing the libraries like that is going to cause you problems.
Well, I can see it from the OP's POV. Having used add_item() from wxEuphoria in hundreded or thousands of places in a very large file, then suddenly needing to include std/sequence.e for one function call that's only used in one place, resulting in the need to manually edit hundreds or thousands of lines of text (just to ad the "wx:" bit) is annoying. A modern text editor should have no problems changing all such references at once - but editing std/sequence.e directly results in fewer lines to audit I suppose.
I can see his point of view, too. But it's still problematic and the wrong solution, even if it seems expedient.
Perhaps we need a way to say "if a namespace conflict exists, instead of throwing an error to warn the programmer, just default to using this namespace and require all calls to the other namespace in this file to be explicitly qualified" or something.
This seems wrong to me. It's introducing slightly different behavior that is likely to be confusing to the programmer.
Matt
14. Re: Conflict add_item
- Posted by DerekParnell (admin) Mar 09, 2015
- 1552 views
I can see his point of view, too. But it's still problematic and the wrong solution, even if it seems expedient.
Perhaps we need a way to say "if a namespace conflict exists, instead of throwing an error to warn the programmer, just default to using this namespace and require all calls to the other namespace in this file to be explicitly qualified" or something.
This seems wrong to me. It's introducing slightly different behavior that is likely to be confusing to the programmer.
I'm with Matt on this one.
The most straight forward method is to put the routine that uses add_item() from sequence.e in its own file and make it public or export.
15. Re: Conflict add_item
- Posted by jimcbrown (admin) Mar 09, 2015
- 1522 views
I can see his point of view, too. But it's still problematic and the wrong solution, even if it seems expedient.
I never said otherwise.
Perhaps we need a way to say "if a namespace conflict exists, instead of throwing an error to warn the programmer, just default to using this namespace and require all calls to the other namespace in this file to be explicitly qualified" or something.
This seems wrong to me. It's introducing slightly different behavior that is likely to be confusing to the programmer.
I'm with Matt on this one.
The most straight forward method is to put the routine that uses add_item() from sequence.e in its own file and make it public or export.
add_item() from sequence.e isn't being used, it just happens to be there and happens to be causing a conflict.
However, you're both right. The solution is that simple - whatever the OP needs from sequence.e - pull that into its own file.
16. Re: Conflict add_item
- Posted by unsteady Mar 09, 2015
- 1505 views
I have read the different suggestions by the developers.
Everything really depends upon how the independent programmer works. In my case, I personally use half a s dozen languages or supervise people using over 12 languages. Even now, I repeatedly make the mistake of
if condition
endif
to be reminded first by the euphora interpreter about the missing "then" and later again when "endif" is nor recognised, and I have to go in and change it to "end if".
Same happens repeatedly to me in
for condition
next for
to be reminded of the missing "do" and later reminded that "next" is not accepted. So I have to go and change to "end for" To you the developers, the several .e that you have created are very important. To me I use the odd one casually. Therefore, to me the important item in my work is wxeud.e
In my work, sequence.e and the other std includes are used only rarely. I usually bring these directly in the folder where my main program resides. I then have to look at the dependencies
include error.e
include types.e
include search.e
include sort.e
and have to bring them in in the same folder. I often create folders of my current work in a separate drive and a separate folder, so I just copy all my "tools" there. It is only when two identical named functions exist in two of my includes that I have problems, as I did in this instance. In reality, it has happended for the first time In any of the programming languages I have worked with. Often though, such conflict arises from the use of the same function names (or global variable names) in my own creations, and then I slap myself. At the same time I do not admonish any of the programmers doing the same mistake. I recognise that it can and does happen.