Pages: 1 2 3 »
  Print  
Author Topic: Encapsulating EDL types and functions in their own namespace  (Read 6498 times)
Offline (Male) polygone
Posted on: March 21, 2013, 05:50:40 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
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:

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, using std::list; or using namespace std;, 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.

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.

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.
« Last Edit: March 21, 2013, 05:52:30 PM by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: March 22, 2013, 01:54:20 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
You don't need to wait for me or the new parser to do this. Just start moving shit into namespace enigma_user, 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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) forthevin
Reply #2 Posted on: March 22, 2013, 02:26:39 PM

Contributor
Joined: Jun 2012
Posts: 167

View Profile
Good point about not waiting. In regards to the namespace name, I think Josh's suggestion of "enigma_user" sounds good.
Logged
Offline (Male) polygone
Reply #3 Posted on: March 22, 2013, 03:38:38 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
Sounds fine it me, I might have gone for enigma_local but it doesn't really matter what it's called :F

Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) polygone
Reply #4 Posted on: March 25, 2013, 05:38:31 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
Is this then on your todo list forthevin? Just so I know.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) forthevin
Reply #5 Posted on: March 25, 2013, 10:30:55 AM

Contributor
Joined: Jun 2012
Posts: 167

View Profile
Yes, it is on my todo list.
Logged
Offline (Male) polygone
Reply #6 Posted on: April 08, 2013, 07:05:30 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
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.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) Goombert
Reply #7 Posted on: April 19, 2013, 10:56:22 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2993

View Profile
When a proper implementation is layed out and more explicit instructions given I will begin to tackle this.  (Y)
« Last Edit: April 20, 2013, 02:20:05 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Male) polygone
Reply #8 Posted on: April 27, 2013, 02:46:00 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
It would be a good time to do it since there are few commits right now.
« Last Edit: April 28, 2013, 02:04:03 PM by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) forthevin
Reply #9 Posted on: April 28, 2013, 01:40:09 PM

Contributor
Joined: Jun 2012
Posts: 167

View Profile
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.
Logged
Offline (Male) polygone
Reply #10 Posted on: April 28, 2013, 01:45:38 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
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.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) polygone
Reply #11 Posted on: April 28, 2013, 02:07:58 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
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.
« Last Edit: April 28, 2013, 02:09:53 PM by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) forthevin
Reply #12 Posted on: April 28, 2013, 02:45:10 PM

Contributor
Joined: Jun 2012
Posts: 167

View Profile
No, they are actually available, I tested it myself. The solution is that I put:

Code: [Select]
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.
Logged
Offline (Male) Josh @ Dreamland
Reply #13 Posted on: April 28, 2013, 04:24:39 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
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, namespace enigma_user { using ::var; using ::variant; } appears.

When you guys are ready, tell me, and I'll make the very few changes necessary to change from :: to ::enigma_user.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) polygone
Reply #14 Posted on: April 28, 2013, 04:29:40 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
No, they are actually available, I tested it myself. The solution is that I put:

Code: [Select]
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?
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Pages: 1 2 3 »
  Print