Page 4 of 123

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:50 am
by juizzysquirt
Can we still declare uninitialized ones like this?

Code: Select all

int x, y, z, angle;

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:51 am
by Major Cooke

Code: Select all

int a1, a2, a3;
int b1 = 1, b2 = 2, b3 = 3;
Sounds like it'll be like this where the type must be the same for all within the commas, and they either all must be declared initialized or not, right?

(ninjasquirt... :P)

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:52 am
by Fishytza
Just wondering one thing.

Is ZScript going to accept the following syntax?

Code: Select all

somevar = piff == 221 ? result1 : result2;
Or do I still have to rely on?

Code: Select all

if(piff == 221)
{
    somevar = result1;
}
else
{
    somevar = result2;
}

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:53 am
by Major Cooke
DECORATE supports ternary operators so I see no reason why zscript shouldn't.

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:54 am
by Graf Zahl
I'll make it sane (i.e the way C does it.)
I see no point explaining this insane construct as it won't survive the next hour... :twisted:.

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:54 am
by Graf Zahl
Major Cooke wrote:DECORATE supports ternary operators so I see no reason why zscript shouldn't.

Well, of course it does.

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:55 am
by Major Cooke
Which means requiring them all to be declared initialized, and be at the top of the class.

Code: Select all

int a1 = 0, a2 = 0, a3 = 0;

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 4:56 am
by Major Cooke
Graf Zahl wrote:Well, of course it does.
Oh snap, I just recalled ACS doesn't support ternary operators. That would explain why he asked.

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 5:01 am
by Fishytza
I wasn't asking because of ACS. I was asking because, to me, it's a little more convenient to be able to declare

Code: Select all

f = some_expression ? r1 : r2;
EDIT:
Major Cooke wrote:DECORATE supports ternary operators
I had no idea. >_<

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 5:02 am
by Graf Zahl
Ok then, now

Code: Select all

			int localint = 0, localotherint = 1, i, j;
is doing what any sane person would expect...

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 5:03 am
by Major Cooke
So initialized vars goes first, non-initialized last?

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 5:08 am
by Graf Zahl
No, you can freely mix them, now each one creates a separate node that includes both its name and value.

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 5:11 am
by Major Cooke
Okay, so auto detection for type is only for constants then, it appears.

On that note, I noticed you used the word "double" instead of "float" earlier. We're to use double then? Or are you allowing both words to translate into the same thing internally, or will they be truly different?

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 5:16 am
by Graf Zahl
The language has support for single precision floats. But for the time being these are disabled and if they ever come to pass, only in arrays, classes or structs. There's still people around who actually believe that having smaller sized versions of numeric types is a good idea (which I disagree with, let 'em burn!)

Re: ZScript Discussion

Posted: Wed Oct 19, 2016 5:32 am
by Major Cooke
Double it is! Wiki updated. I'm glad the naming convention is actually correct now, because for a while that did confuse me when the word 'float' translated into 'double' in DECORATE. (Even before that, it was fixed_t. So happy that's gone.)

On that note, assuming non-constant strings/names are/will be a thing, I'm assuming we'll have access to functions like stricmp, yes?