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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top