polygone
 Joined: Mar 2009
Posts: 794
|
 |
Posted on: March 21, 2013, 10:50:40 PM |
|
|
In response to a suggestion that Josh has been throwing around for a while I would like to start a topic about this so it can be further discussed. I for one would like to see it happen. These are some previous quotes from the Christmas plan topic about it: Quote from: Josh @ Dreamland on December 27, 2012, 05:04:32 PM Also, who among you is interested in the idea of encapsulating EDL types and functions in their own namespace? It would make it easier to deal with noise from library implementations, but it would require putting lots of shit into that namespace and using lots of shit from STDC.
In other words, we'd no longer have problems with time or list being illegal variable names unless the user specifically said, [snip=EDL]using std::list;[/snip] or [snip=EDL]using namespace std;[/snip], which I intend to unify between all viable backends (meaning, in JavaScript as well).
The new parser is much, much more adept at making these distinctions, so I can probably get it to allow using types and shit as variable names (especially in compatibility mode), but this would be a fix-all.
Quote from: forthevin on December 29, 2012, 02:18:04 AM Encapsulation of EDL types and functions would be nice, especially if it solves the problems with "time" and "list" being used as variable names. How easy would it be to set up the system such that EDL types and functions can reside in both the global namespace and the EDL namespace? If it is easy, I would like the system to be set up that way, since that should enable easy step-wise migration.
Quote from: Josh @ Dreamland on December 29, 2012, 02:52:06 AM Simple as placing "using namespace <name here>;" in the global scope. Just like you would any other namespace. I'll set ENIGMA up to read from :: or ::edlwhatever based on a macro. After everything's migrated, or we think everything's migrated, you'll just flip that flag and try compiling.
|
|
|
Josh @ Dreamland
Prince of all Goldfish
 Joined: Feb 2008
Posts: 2,950
|
 |
Reply #1 Posted on: March 22, 2013, 06:54:20 PM |
|
|
|
You don't need to wait for me or the new parser to do this. Just start moving shit into [snip]namespace enigma_user[/snip], or whatever, and then use that namespace from the global scope.
It's actually not difficult to make JDI only read a certain namespace, but I'd rather it wait until the new compiler is out just because we'll have to do it twice, and I don't feel like dealing with merge conflicts when I pour master back into enigma-jdi.
|
|
|
forthevin
 Joined: Jun 2012
Posts: 167
|
 |
Reply #2 Posted on: March 22, 2013, 07:26:39 PM |
|
|
|
Good point about not waiting. In regards to the namespace name, I think Josh's suggestion of "enigma_user" sounds good.
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #3 Posted on: March 22, 2013, 08:38:38 PM |
|
|
|
Sounds fine it me, I might have gone for enigma_local but it doesn't really matter what it's called :F
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #4 Posted on: March 25, 2013, 10:38:31 AM |
|
|
|
Is this then on your todo list forthevin? Just so I know.
|
|
|
forthevin
 Joined: Jun 2012
Posts: 167
|
 |
Reply #5 Posted on: March 25, 2013, 03:30:55 PM |
|
|
|
Yes, it is on my todo list.
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #6 Posted on: April 08, 2013, 12:05:30 PM |
|
|
|
I just realized this is going to be a bitch to do with all the continuous commits, I think it needs to be planned properly.
|
|
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #8 Posted on: April 27, 2013, 07:46:00 PM |
|
|
|
It would be a good time to do it since there are few commits right now.
|
|
|
forthevin
 Joined: Jun 2012
Posts: 167
|
 |
Reply #9 Posted on: April 28, 2013, 06:40:09 PM |
|
|
|
I have moved some of the user functions and variables into the enigma_user namespace. I will move more later, but I will stay outside of collisions and graphics, to avoid moving things others are moving.
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #10 Posted on: April 28, 2013, 06:45:38 PM |
|
|
Quote from: forthevin on April 28, 2013, 06:40:09 PM I have moved some of the user functions and variables into the enigma_user namespace. I will move more later, but I will stay outside of collisions and graphics, to avoid moving things others are moving.
It's alright nobody is working on any collision or graphics functions right now, I don't think. Now's the best time to move everything, and all at once.
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #11 Posted on: April 28, 2013, 07:07:58 PM |
|
|
|
Ok I see you've just committed. The problem is those functions aren't going to be available now to people using ENIGMA. This is why it's best to do the whole wrong at once, or at least quickly. Maybe it would be a better idea to branch off actually.
|
|
|
forthevin
 Joined: Jun 2012
Posts: 167
|
 |
Reply #12 Posted on: April 28, 2013, 07:45:10 PM |
|
|
|
No, they are actually available, I tested it myself. The solution is that I put:
namespace enigma_user {};
using namespace enigma_user;
in SHELLmain.cpp, such that the namespace is available to the users, like Josh instructed. That way, user variables/functions that reside in either the global or enigma_user namespace are available to the user.
|
|
|
Josh @ Dreamland
Prince of all Goldfish
 Joined: Feb 2008
Posts: 2,950
|
 |
Reply #13 Posted on: April 28, 2013, 09:24:39 PM |
|
|
|
The only thing you should watch out for is some of the existing hacks. Most of them are local to the math header. I define the bessel functions to be declared with a bessel_ prefix to avoid conflicts with variable names like y1. There are other, similar hacks. Removing those will break some games. When the move is finished, the macros that do that will need to be removed, and the bessel functions simply declared in namespace enigma_user to call the corresponding stdc functions in ::.
Make sure, also, that somewhere in the code, [snip=cpp]namespace enigma_user { using ::var; using ::variant; }[/snip] appears.
When you guys are ready, tell me, and I'll make the very few changes necessary to change from :: to ::enigma_user.
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #14 Posted on: April 28, 2013, 09:29:40 PM |
|
|
Quote from: forthevin on April 28, 2013, 07:45:10 PM No, they are actually available, I tested it myself. The solution is that I put:
namespace enigma_user {};
using namespace enigma_user;
in SHELLmain.cpp, such that the namespace is available to the users, like Josh instructed. That way, user variables/functions that reside in either the global or enigma_user namespace are available to the user.
Shouldn't you commit that then?
|
|
|
|