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
Author Topic: Another choice.  (329,055 Views)
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Posted on: March 12, 2010, 02:45:55 PM
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.
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #1 Posted on: March 12, 2010, 02:51:35 PM
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"
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #2 Posted on: March 12, 2010, 03:23:31 PM
"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.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #3 Posted on: March 12, 2010, 03:51:08 PM
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.

Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #4 Posted on: March 12, 2010, 04:12:43 PM
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"
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #5 Posted on: March 12, 2010, 04:17:19 PM
QuoteHmmm.....
...
Hmmmmm......
...
DAMNIT!

Yep. Hence the poll.

I'd rather not distinguish between events, though.
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #6 Posted on: March 12, 2010, 04:21:04 PM
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...
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #7 Posted on: March 12, 2010, 05:22:27 PM
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.
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #8 Posted on: March 12, 2010, 05:31:03 PM
You should totally call the language gmc++
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #9 Posted on: March 12, 2010, 06:31:09 PM
localvar then, maybe?
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #10 Posted on: March 12, 2010, 06:52:45 PM
Well, I'd take localv over that. Two less letters, and such. May as well just go with local, in the end.
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #11 Posted on: March 12, 2010, 07:03:37 PM
Quote from: Josh @ Dreamland. on March 12, 2010, 06:52:45 PM
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
Offline (Unknown gender) The 11th plague of Egypt

Member
Joined: Dec 2009
Posts: 274
View profile
Reply #12 Posted on: March 12, 2010, 07:58:54 PM
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".
Offline (Unknown gender) luiscubal

Member
Joined: Jun 2009
Posts: 452
View profile
Reply #13 Posted on: March 12, 2010, 08:35:39 PM
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.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #14 Posted on: March 12, 2010, 08:45:24 PM
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. >_<
Pages: 1 2 3 4 5