Poll
Question: How should an object-local and a script-local integer be defined?
local int, int - 12 (63.2%)
int, var int - 6 (31.6%)
localv int, int - 0 (0%)
Special Event - 1 (5.3%)
Total Members Voted: 19

Pages: 1 2 3 4 5 »
  Print  
Author Topic: Another choice.  (Read 47799 times)
Offline (Male) Josh @ Dreamland
Posted on: March 12, 2010, 09:45:55 am

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

View Profile Email
In R3, you were allowed to say "int a;" in a code piece to declare "a" as C++'s fastest type. To declare it as a local variable to the object, however, I made you say "localv int a;". Well, that system was brutally easy to implement. However, it's not so convenient to type.

When I started the project, I was enamored by how similar C++ and GML were. I saw "var" as a data type; GM's only data type.  It was only logical that var should be a class.

However, long, long ago, NoodleNog suggested that to declare script-local variables, of type "int" for example, you should use "var int" rather than just "int." This makes it a bit of a hassle to declare script-locals, but then actual object-local variables are simply declared as "int."

He was presenting this to me as I suggested ambiguating the word "local" to use. Locals would be declared one-time, preferably in create events but technically in any event, as "local int a;".

My first choice was actually to have Ism add an event for such declarations; in this event, you would have only your locals declared. It seems rather unprofessional in retrospect, but would technically be as easy as adding semicolons and copying over the code to the front of the structure. :P It would make my life easier, but it would leave a bad feeling in my stomach and would cause Ism a good amount of work, possibly delaying the project further.

I was going to just go with the first option (which I will cast a vote on this time), but I figured I'd give you all a chance to toss it around and/or shoot flames at it first.

To clarify, no outcome of this poll will affect backwards-compatibility with Game Maker. This is purely an extension of the language. Undeclared variables will be treated as local vars. "localv var" and "local var" are meaningless.

Anyway, same drill as last time.
Peace.
« Last Edit: March 12, 2010, 07:48:47 pm by Josh @ Dreamland » 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) retep998
Reply #1 Posted on: March 12, 2010, 09:51:35 am

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
IF YOU MAKE ME TO HAVE TO DECLARE LOCAL JUST TO MAKE A DAMN OBJECT-LOCAL VARIABLE I'M GOING TO KILL YOU AND MAKE MY OWN PRIVATE BUILD OF ENIGMA JUST TO HAVE IT AS A SIMPLE INT.

I vote "int, var int"
Logged
Offline (Male) Rusky
Reply #2 Posted on: March 12, 2010, 10:23:31 am

Resident Troll
Joined: Feb 2008
Posts: 954
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
"int, var int" is probably closest to GM's functionality, and omitting the type would default to var as in GM. So long as code from GM behaves the same way in Enigma, it should be okay. It would be nice to be able to disable automatic member creation and manage members yourself, though, in which case "int foo" would be script-local like C++. Not sure how I would resolve this in the long run; I really dislike GM's behavior.
Logged
Offline (Male) Josh @ Dreamland
Reply #3 Posted on: March 12, 2010, 10:51:08 am

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

View Profile Email
retep998--
That was what I was thinking at first, but then I realized that I would be saying "var int" a lot more often than "local int." And if I forgot the "var," I'd be in danger of bizarre performance.

Consider

for (var int i = 0; i < 10; i++)
vs
for (int i = 0; i < 10; i++)

If ENIGMA moved the initialization of the local in the second example to the constructor of the object (as it should, technically), "i" would resume at 10 and the loop wouldn't do anything. That would be bad. :v:

Not to mention you'd be wasting the memory if you forgot the var. Though, that goes both ways.

Rusky--
Not anymore, I don't think. GM7(?) implements this syntax:

global var a;

Which they advertise as eliminating the need to use "global." in future references.
Implementing "local int a" would be no different.

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) retep998
Reply #4 Posted on: March 12, 2010, 11:12:43 am

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Hmmm.....
...
Hmmmmm......
...
DAMNIT!
...
How about...
"int, var int" during creation events
and
"local int, int" during all other events

And also, it's "globalvar" not "global var"
Logged
Offline (Male) Josh @ Dreamland
Reply #5 Posted on: March 12, 2010, 11:17:19 am

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

View Profile Email
Quote
Hmmm.....
...
Hmmmmm......
...
DAMNIT!

Yep. Hence the poll.

I'd rather not distinguish between events, though.
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) retep998
Reply #6 Posted on: March 12, 2010, 11:21:04 am

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
We're screwed either way....
Hmmmmmm.....
This is where I hate enigma (gm plus c++ = gmc++ o_0 The gmc is really low to begin with, so that ain't saying much about enigma)
Eh, I change my vote to the first thingy "local int, int"
I prefer the normal c++ way of
class shithead{
public:
string typeofshit;
};
gmc++ just doesn't work very well...
Logged
Offline (Male) Josh @ Dreamland
Reply #7 Posted on: March 12, 2010, 12:22:27 pm

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

View Profile Email
Vote changing's enabled, I believe. Feel free.

There was another problem with operator++, but I don't think we need a poll for that.
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) retep998
Reply #8 Posted on: March 12, 2010, 12:31:03 pm

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
You should totally call the language gmc++
Logged
Offline (Male) Rusky
Reply #9 Posted on: March 12, 2010, 01:31:09 pm

Resident Troll
Joined: Feb 2008
Posts: 954
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
localvar then, maybe?
Logged
Offline (Male) Josh @ Dreamland
Reply #10 Posted on: March 12, 2010, 01:52:45 pm

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

View Profile Email
Well, I'd take localv over that. Two less letters, and such. May as well just go with local, in the end.
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) retep998
Reply #11 Posted on: March 12, 2010, 02:03:37 pm

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Well, I'd take localv over that. Two less letters, and such. May as well just go with local, in the end.

Add support for all 3 then
localvar
localv
local
:D
Logged
Offline (Unknown gender) The 11th plague of Egypt
Reply #12 Posted on: March 12, 2010, 02:58:54 pm
Member
Joined: Dec 2009
Posts: 274

View Profile
This is another case of GML vs C++

We'll have a GM audience, but we want to be serious too.

I'd vote for int and var int because it would make GM ports easier, but if local int is more C++ friendly, then go for it.

We don't need a var since we can use all the types we want. If we really want var to mean temporary, then call it "temp".
Logged
Offline (Unknown gender) luiscubal
Reply #13 Posted on: March 12, 2010, 03:35:39 pm
Member
Joined: Jun 2009
Posts: 452

View Profile Email
Some languages allow post-fix types, such as ActionScript.

var x : int = 2;

What about this possibility?
Basically, every single local/global declaration rule would be the same as GM's, except for an optional suffix. This doesn't seem to conflict with GM's way, although I'm not sure I understood the problem.
Logged
Offline (Male) Josh @ Dreamland
Reply #14 Posted on: March 12, 2010, 03:45:24 pm

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

View Profile Email
The 11th plague of Egypt--
Neither interfere with porting GM games to ENIGMA; it's a new concept to GM users and it can be interpreted either way.

luis--
Some languages are fuck ugly and require too much typing AND too many shift presses. >_<
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
Pages: 1 2 3 4 5 »
  Print