ZScript Discussion

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Re: ZScript Discussion

Postby Major Cooke » Tue Oct 18, 2016 12:43 pm

Graf Zahl wrote:No, they won't. Constants go into the main block. They are not defaults they are class properties, not instance properties.


Corrected on the wiki. What about non-constants though?
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Graf Zahl » Tue Oct 18, 2016 12:54 pm

Variable declarations go into the class scope Initialization has to be part of Default, because you may want to initialize them differently in subclasses. The way ZDoom initializes actors the constructor is a bad place for that. That part hasn't been defined yet, though.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Major Cooke » Tue Oct 18, 2016 12:55 pm

Understood. I take it they will be at some point, as user variables being replaced will make it hard to update to ZScript on first merge without the ability to define them.
By the way...

Code: Select allExpand view
class CFlameMissile : FastProjectile native


Where and when will we need the "native" keyword?
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Graf Zahl » Tue Oct 18, 2016 1:19 pm

The 'native' keyword means that this class contains a native definition in the engine and tells the compiler to connect the script class with the internal one, just like it does in DECORATE. You won't be able to use this in user side code at all.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Xaser » Tue Oct 18, 2016 6:21 pm

To echo Gez's sentiment from the previous thread, I'd like to see the "Default" block be renamed to something like "Properties". I get that it means "default values to set on a new instance of this class", but that definition's going to escape users not familiar with the internals. At first glance it looks like the "wrong" word to use in such a context.

[EDIT] For the sake of contributing something that's not a syntax nitpick: the thing I'm most keen to see is non-anonymous functions of some sort (i.e. custom action functions). Being able to call something like A_FirePsychicPower(...) and move all the stuff that goes into that into a sane function def, that'd make a world of difference.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: ZScript Discussion

Postby ZzZombo » Wed Oct 19, 2016 12:55 am

So I guess it's possible to have an array of references to actors, but not other kinds of containers like dictionaries and whatnot, you know, more advanced ones?
ZzZombo
 
Joined: 16 Jul 2012

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 1:10 am

@Xaser: viewtopic.php?f=4&t=53797

Eventually. Probably won't happen on the first merge though.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 3:04 am

Xaser wrote:[EDIT] For the sake of contributing something that's not a syntax nitpick: the thing I'm most keen to see is non-anonymous functions of some sort (i.e. custom action functions). Being able to call something like A_FirePsychicPower(...) and move all the stuff that goes into that into a sane function def, that'd make a world of difference.


Let's go at it step by step. The grammar supports such functions but right now the code generator does not. My first priority is to make the stuff that DECORATE already supports work - because after that I can start cleaning up and restructuring the code generator. And before that isn't done it makes little sense to implement more features.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 3:05 am

ZzZombo wrote:So I guess it's possible to have an array of references to actors, but not other kinds of containers like dictionaries and whatnot, you know, more advanced ones?



Again: What's the point of going after step 20 first, when the implementation right now is only at step 5? The groundwork in the grammar is there, but this all needs to be implemented, and that's not a simple task to get working.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 5:07 am

Here's something I want to get a public opinion first, because unlike the const syntax I believe this is really going to confuse users.
I can't help but notice that the grammar has taken some really bad influence from Lua and this looks like another such example:

If you want to declare initialized local variables it has to be done like this currently:

Code: Select allExpand view
         int localint, localotherint, i, j = 0,1,2,3;


instead of what pretty much everybody would expect:

Code: Select allExpand view
         int localint = 0, localotherint = 1, i = 2, j = 3;


It's only because I already knew about the Lua stuff that I could guess where this was going when the second approach did not work, but if I as a programmer cannot see the sense in here, what about the future user of this tool?

Edit: It gets worse. This passes the parser but the result is bogus:

Code: Select allExpand view
         double localfloat = 1.234, localfloatnotinit;


No, it doesn't declare two variables, it only declares one, 'localfloatnotinit' is considered an initializer for a non-existent second variable. I guess I don't wait for opinion, this is a disaster just waiting to happen with the given syntax.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby juizzysquirt » Wed Oct 19, 2016 5:27 am

First example feels really, really awkward. I get the idea of "efficiency" there but just imagining reading several lines with 5 or more variables (of someone else's code) makes my head hurt.
Last edited by juizzysquirt on Wed Oct 19, 2016 5:28 am, edited 1 time in total.
User avatar
juizzysquirt
 
Joined: 04 Jan 2009
Location: Knee-Deep in L.A. Meltdown

Re: ZScript Discussion

Postby Nash » Wed Oct 19, 2016 5:27 am

I got cross-eyed reading that. That looks confusing as hell. I hope you can change it to the usual, expected syntax. I'm already used to writing like this for many years:

Code: Select allExpand view

int dx 
= 1,
    dy = 2,
    dz = 3;
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 5:33 am

Graf Zahl wrote:Edit: It gets worse. This passes the parser but the result is bogus:

Code: Select allExpand view
         double localfloat = 1.234, localfloatnotinit;


No, it doesn't declare two variables, it only declares one, 'localfloatnotinit' is considered an initializer for a non-existent second variable. I guess I don't wait for opinion, this is a disaster just waiting to happen with the given syntax.


So we basically need to go with:

Code: Select allExpand view
int num1 = 1;
int num2 = 2;


and your above example is a no-go?

I don't mind that one bit honestly. Since this is how user vars had to be treated, I'm used to it -- with the added bonus of zscript's capable of being assigned immediately instead of relying on the states to do it.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Gez » Wed Oct 19, 2016 5:38 am

Graf Zahl wrote:Here's something I want to get a public opinion first, because unlike the const syntax I believe this is really going to confuse users.
I can't help but notice that the grammar has taken some really bad influence from Lua and this looks like another such example:

If you want to declare initialized local variables it has to be done like this currently:

Code: Select allExpand view
         int localint, localotherint, i, j = 0,1,2,3;

Indeed I don't like it. Not that declaring a lot of variable in the same line is good practice anyway, but separating the variables from their initial value seems like a good way of getting both lists out of syncs if variables get added or removed.

E.g. suppose someone tries to refactor the code to see if localotherint is really needed, and so comments it out for a test...
Code: Select allExpand view
         int localint, /*localotherint,*/ i, j = 0,1,2,3;

Yeesh! With the C-style syntax there's no risk of that happening.
Gez
 
 
 
Joined: 06 Jul 2007

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 5:44 am

Thanks. That list of reactions pretty much sums up my own. Of course I am changing it.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest