Pages: 1 2 3
Author Topic: Encapsulating EDL types and functions in their own namespace  (131,053 Views)
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
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.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
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.
Offline (Unknown gender) forthevin

Contributor
Joined: Jun 2012
Posts: 167
View profile
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.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
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

Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #4 Posted on: March 25, 2013, 10:38:31 AM
Is this then on your todo list forthevin? Just so I know.
Offline (Unknown gender) forthevin

Contributor
Joined: Jun 2012
Posts: 167
View profile
Reply #5 Posted on: March 25, 2013, 03:30:55 PM
Yes, it is on my todo list.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
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.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #7 Posted on: April 20, 2013, 03:56:22 AM
When a proper implementation is layed out and more explicit instructions given I will begin to tackle this.  (Y)
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
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.
Offline (Unknown gender) forthevin

Contributor
Joined: Jun 2012
Posts: 167
View profile
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.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
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.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
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.
Offline (Unknown gender) forthevin

Contributor
Joined: Jun 2012
Posts: 167
View profile
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.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
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.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
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?
Pages: 1 2 3