Discussion New Language - Discussion

Xienoph

You can change this now in User CP.
Reaction score
43
1. Not sure what you meant by free form locals. Basically, you should be able to declare local variable anywhere, not just at the start of a function block. So that's probably free form locals are.

2. Which part don't you understand? Maybe it'll help if you know what curried functions are?

Not an expert in Python, but I know enough to write a simple trace route.
 

tooltiperror

Super Moderator
Reaction score
231
Eh, the problem with free-form locals, is you need to make sure they can`t be put inside textmacros or loops. If you put a local in a textmacro and ran it a few times, it would declare the same local a few times, which would screw up the JASS.

JASS:
.
loop
set x = x + 1
local string str = "lol!"
exitwhen x = 7
endloop


Pretty much compiles to:

JASS:
.
set x = x + 1
local string str = "lol!"
set x = x + 1
local string str = "lol!"
set x = x + 1
local string str = "lol!"
set x = x + 1
local string str = "lol!"
set x = x + 1
local string str = "lol!"
set x = x + 1
local string str = "lol!"
set x = x + 1
local string str = "lol!"


And you can`t declare locals more than once.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
1. Not sure what you meant by free form locals. Basically, you should be able to declare local variable anywhere, not just at the start of a function block. So that's probably free form locals are.

2. Which part don't you understand? Maybe it'll help if you know what curried functions are?

Not an expert in Python, but I know enough to write a simple trace route.

2. I don't see the point, really...
And if you know any Python, then your more than welcome to help develop this if you'd like(as soon as it's far along enough to make it worth making it publicly developed).

Eh, the problem with free-form locals, is you need to make sure they can`t be put inside textmacros or loops. If you put a local in a textmacro and ran it a few times, it would declare the same local a few times, which would screw up the JASS.

And you can`t declare locals more than once.

Honestly, I'm not sure free-form locals are a good thing... It can make the syntax messy, which is the very last thing I want on this entire project.
 

Jesus4Lyf

Good Idea™
Reaction score
397
I see nothing wrong with freeform locals. Declaring a variable twice is picked up by PJASS and is not the compiler's problem.

When you see local type var=val in the code, move "local type var" to the top and change the line to "set var=val". This solves enough to make it useful.

EG:
JASS:
loop
set x = x + 1
local string str = "lol!"
exitwhen x = 7
endloop

-->
JASS:
local string str
loop
set x = x + 1
set str = "lol!"
exitwhen x = 7
endloop
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
If enough people want it, and if it's possible in Python, then I'll add it.
That's pretty much my stance on every feature, as long as it's a reasonable one.
 

tooltiperror

Super Moderator
Reaction score
231
cJASS Manual said:
The parser will move all local variable declarations to the beginning of the function. As in JASS2 variables can be initialized inside the declaration, cJass will also move the initialization if the variable is initialized with exact value:

cJASS Manual said:
cJass syntax also lets you declare variables of the same type on the same line, separating them by commas. These variables can also be initialized here:

That looks really pretty.

JASS:
local real x,y,nx,ny


I suggest you add in declaration, separated by semi-colons.
JASS:
.
local unit u = GetTriggerUnit()
local real x = GetUnitX(u); y = GetUnitY(u)


Just have the compiler search for 'local'. If it finds local, it will start looking for the semi-colons. If it finds a semi-colon, bump it down a line, and add local. It will also bring the type down with it. It will turn into this:
JASS:
.
local unit u = GetTriggerUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)


While we're at it, we may as well throw in a | operator. When you come across quotations, ignore what's inside, so that color codes and strings aren't effected. The | will let you whitespace without the compiler knowing.

JASS:
.
 call GetUnit|
                   X|
                      (GetTriggerUnit|
                                              ())

  // Is the same as
 call GetUnitX(GetTriggerUnit())


It looks really stupid in this example, but when you start getting into giant functions, you can split them on one line.

I`ve got a question, is parsing/compiling like working with sub/strings?
 

quraji

zap
Reaction score
144
Multiple declarations should be done like it usually is..same types can be defined on the same line and also initialized, separated by commas.
JASS:

integer i, j = 5, k, t = j
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Let's say you wanted 10 rows per player, 10 columns per row, and 10 cells per column for 12 players?

10*10*10=1000

1000*12=12000.

That's a 4d array. a 3d array of a 10x10 table for each player is 12*10*10 = 1200.

This is a very important thing, that must be implemented.

I agree, I've been waiting for something like this. Especially in combination with operator overloading.

Also, sounds crazy, but if you implement, Stay with me, Three Dimmensional Arrays, and break the size limit, you could do crazy shit.

If the size limit could be broken, don't you think it would have been broken already?

If you want 2d/3d/extended arrays, you should just compile it to use hashtables. They're slower (not that that makes much of a difference), but it makes it safer.

Freeform Locals = fail

Absolutely not. Maybe with the current syntax of using [ljass]local string str = ""[/ljass], but imagine being able to declare iterators where they're actually being used:

JASS:
integer i = 0
loop
    exitwhen i >= 12
    DisplayTextToPlayer(Player(i),0,0,"Hi, player " + I2S(i))
    i++
endloop


While we're at it, we may as well throw in a | operator. When you come across quotations, ignore what's inside, so that color codes and strings aren't effected. The | will let you whitespace without the compiler knowing.

JASS:
.
 call GetUnit|
                   X|
                      (GetTriggerUnit|
                                              ())

  // Is the same as
 call GetUnitX(GetTriggerUnit())


It looks really stupid in this example, but when you start getting into giant functions, you can split them on one line.

At the very least you should just use \ to escape the end of line. It should exist so you can put ridiculously huge functions on second and third lines for readability.


[ljass]or[/ljass] is or. Why would you want to make it less readable?

But I don't see the need for that.

Have you seen object merger textmacros? Gigantic, but if you could split it up, and put it on multiple lines, you can comment each line and explain it. This isn't specific to object merger code, as there are many instances in which you may have long arguments (such as a string that is to be displayed to a player).

For those who are offering feedback: Have you guys tried taking a look at ZINC? There's a lot of cool features in there that is lacking in the suggestions for this 'language'.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
JASS:

local real x, y, nx, ny

This.

Hudge Question: Semi-colon to be or not to be in Onyx?

Also

private / public blocks of globals. ->
JASS:

public globals
// all globals in it are public
endglobals

private globals
// all globals in it are private
endglobals

// BUT....

public globals
// Can still use private keyword
    private unit aUnit = null
    // private global
endglobals
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
> Semi-colon to be or not to be in Onyx?

For endline? I'm considering it.

> private / public blocks of globals.

What would be the point?
 

Sevion

The DIY Ninja
Reaction score
413
> private / public blocks of globals.

The point would be not having to put public or private keywords in front of all of the values.

So, instead of:

JASS:
globals
    private integer i
    private unit u
    private string s
endglobals


You could do

JASS:
private globals
    integer i
    unit u
    string s
endglobals


And compile it to the same as the first example.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
How about a configuration / endconfiguration? Or maybe just private constant global?

JASS:

configuration
    integer MAX_DAMAGE = 4
    real AREA_OF_EFFECT = 200
    string DAMAGE_MESSAGE = "the game"
endconfiguration

// becomes

globals
    private constant integer MAX_DAMAGE = 4
    private constant real AREA_OF_EFFECT = 200
    private constant string DAMAGE_MESSAGE = "the game"
endglobals
 

Sevion

The DIY Ninja
Reaction score
413
Perhaps shorten it to "config"?

I wouldn't want to make this language too complicated.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Why not just leave it out all together, and have everything private by default? Use [ljass]public[/ljass] to make something available outside the library, and 'const' to make it constant.

It's not like you create tons and tons of configurable constant variables, enough to warrant making a config block.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
I don't see the point of private by default.

Also, I'm about 80% familiar with the syntax of Python, so I can start this project soon. I just need to find out how I'm going to do the parsing (using a tool, doing it manually, etc...), and I can start working on it.
 

Xienoph

You can change this now in User CP.
Reaction score
43
Not exactly. You can modify the global you 'pass' to the function, but you can't modify that in a different thread. ForGroup calls do not break the thread.
So what happens if you modify tmpPlayer in a different thread? Is JASS smart enough to lock that variable? Or is JASS ran with JavaScript's multithreading execution model?

How does ZINC pass arguments to the anonymous function?

Lyrae said:
I don't see the point, really...
The benefits: Reusable code, less global variables (tidier code), and it makes it easier to make a spell multi player / unit / cast (Allows a unit to cast the same spell more than once?) instanceable.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
So what happens if you modify tmpPlayer in a different thread? Is JASS smart enough to lock that variable? Or is JASS ran with JavaScript's multithreading execution model?

Warcraft III runs one thread at a time. Other threads will wait for the current thread to finish before they are executed.

As for ZINC's model for passing arguments, I'm not sure. I'm not sure if it allows any to be passed at all, but it's not a big deal to set it to a global or use a function interface and wrapper func.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top