wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Warcraft Editing Tools
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 07-31-2009, 07:51 PM   #2176
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 191

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by Alevice
STructs in c++ can have methods.

Anyway, sucks to hear that Vex :( Oh well, time to redesign then :/

thanks i did not know that!
__________________
Undefined shadow...
Dark_Dragon is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 08-01-2009, 04:56 PM   #2177
Opossum
User
 
Opossum's Avatar
 
Join Date: Mar 2008
Posts: 205

Submissions (4)

Opossum will become famous soon enough (59)Opossum will become famous soon enough (59)

Default

Quote:
Originally Posted by Vexorian
Quote:
Originally Posted by Opossum
Quote:
Originally Posted by JassHelper Manual
Something to point out is the existance of the readonly keyword, it allows code outside the struct to read the variable but not to assign it. It is a nonstandard at the moment, so you shouldn't use it on public releases.

is that still up to date? I've seen several people using readonly (including myself) without ever reporting any bugs. How does it work anyway? Does it just give a compile error whenever a variable is set outside of a struct?

I was supposed to add it to the standard, post in the jasshelper thread to remind me.

Anyway, it is not that important, now that there is inline, an operator that just returns a variable would work the same.

There you go.
Opossum is offline   Reply With Quote
Old 08-01-2009, 11:58 PM   #2178
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

I'd like to suggest Try-Finally blocks. They would be an easy way to insert code at all the exit points of a block. Here is an example:

Collapse JASS:
function F takes boolean b returns integer
    local group g = CreateGroup()
    try
        if b then
            return 1
        else
            return 0
        endif
    finally
        call DestroyGroup(g)
        set g = null
    endtry
endfunction

//translates to:

function F takes boolean b returns integer
    local group g = CreateGroup()
    if b then
        call DestroyGroup(g)
        set g = null
        return 1
    else
        call DestroyGroup(g)
        set g = null
        return 0
    endif
    call DestroyGroup(g)
    set g = null
endfunction
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 08-02-2009, 02:20 AM   #2179
Earth-Fury
Two Blue
 
Earth-Fury's Avatar
 
Join Date: Mar 2003
Posts: 2,179

Submissions (7)

Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)

Send a message via MSN to Earth-Fury
Default

Quote:
Originally Posted by Strilanc
I'd like to suggest Try-Finally blocks. They would be an easy way to insert code at all the exit points of a block. Here is an example:

Collapse JASS:
function F takes boolean b returns integer
    local group g = CreateGroup()
    try
        if b then
            return 1
        else
            return 0
        endif
    finally
        call DestroyGroup(g)
        set g = null
    endtry
endfunction

//translates to:

function F takes boolean b returns integer
    local group g = CreateGroup()
    if b then
        call DestroyGroup(g)
        set g = null
        return 1
    else
        call DestroyGroup(g)
        set g = null
        return 0
    endif
    call DestroyGroup(g)
    set g = null
endfunction

That's a horrible syntax. Adding an additional level of indentation, and it only makes sense in the root level of the function. Also, "Try-Finally" has indications of exception catching, which is misleading.

Something more like this would solve those problems:
Collapse JASS:
function Whatever takes nothing returns integer
    // Body
finally
    // Whatever gets put before every return
endfunction

Precedence exists in JASS for such a construct. (If-then-else)
__________________
Useful Links:
My Resources:
Good Resources:
Search
Tutorials
Ability Guide

UnitMaxState
BonusMod

AutoIndex
ARGB
TimerUtils

Earth-Fury is offline   Reply With Quote
Old 08-02-2009, 03:46 AM   #2180
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

It most certainly is useful at non-function root levels. You might only require cleanup inside one branch of an IF block, or you might require cleanup over each iteration of a loop. Throw in a couple return or exitwhen statements, and suddenly try-finally is extremely useful.

Here is an example. I'm sure you can come up with others.
Collapse JASS:
function GetPlayerWithUnit takes unit u returns player
    local group units
    local integer i = 0
    loop
        exitwhen i >= numPlayers
        try
            set units = GetPlayerUnitsAll(Player(i))
            if GroupContainsUnit(units, u) then
                return Player(i)
            endif
        finally
            call DestroyGroup(units)
            set units = null
        endtry
        set i = i + 1
    endloop
    return null
endfunction

I disagree with your aversion to indentation. By adding a level of indentation I can remove redundant cleanup code and simplify the control structures. It's a net gain.

Making 'finally' a weird part of the function is a horrible abuse of syntax. It goes against basic scoping rules for the 'function finally block' to have access to the locals declared in the function body. Variables should be declared outside a block in order for following blocks to see them [yes, I do hate the 'globals' block].
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 08-02-2009 at 03:47 AM.
Strilanc is offline   Reply With Quote
Old 08-02-2009, 05:22 AM   #2181
MindWorX
Level 1 Neothelid


Tools Moderator
 
Join Date: Mar 2004
Posts: 254

Submissions (2)

MindWorX has a spectacular aura about (147)

Default

I have to agree with Earth-Fury on the naming. It's seriously bad, as there's no exception catching, and that's kinda the essence of the try block.
MindWorX is offline   Reply With Quote
Old 08-02-2009, 11:58 AM   #2182
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by MindWorX
I have to agree with Earth-Fury on the naming. It's seriously bad, as there's no exception catching, and that's kinda the essence of the try block.

I agree that is the usual use of a try block in other languages (to catch exceptions). But the secondary use is for cleanup.

If you want alternatives: C# has the 'using' block, which would also work well for this purpose.

Collapse JASS:
using group g = CreateGroup()
    ...
        return
    ...
endusing

translates to:

Collapse JASS:
local group g
...
    set g = CreateGroup()
    ...
        call DestroyGroup(g)
        set g = null
        return
    ...
    call DestroyGroup(g)
    set g = null

The downside is that it only works for types the compiler understands.
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 08-02-2009 at 11:58 AM.
Strilanc is offline   Reply With Quote
Old 08-02-2009, 03:35 PM   #2183
Earth-Fury
Two Blue
 
Earth-Fury's Avatar
 
Join Date: Mar 2003
Posts: 2,179

Submissions (7)

Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)

Send a message via MSN to Earth-Fury
Default

Quote:
Originally Posted by Strilanc
It most certainly is useful at non-function root levels. You might only require cleanup inside one branch of an IF block, or you might require cleanup over each iteration of a loop. Throw in a couple return or exitwhen statements, and suddenly try-finally is extremely useful.

...

I disagree with your aversion to indentation. By adding a level of indentation I can remove redundant cleanup code and simplify the control structures. It's a net gain.

Touche.

Quote:
Originally Posted by Strilanc
Making 'finally' a weird part of the function is a horrible abuse of syntax. It goes against basic scoping rules for the 'function finally block' to have access to the locals declared in the function body. Variables should be declared outside a block in order for following blocks to see them [yes, I do hate the 'globals' block].

Again, touche. I wonder why vex hasn't just dropped the "globals endglobals" shit. At worst, just prefix global declaration lines with "global" the same way locals work.


I would suggest "begin" instead of "try", but "endbegin" sounds retarded. Which brings me to another question: why not unify all the "end"s in to a single keyword? It's easy to determine what an end refers to from the compilers standpoint, and it would reduce the amount of typing required. There would be no ambiguity from the point of reading code, due to indentation. And those that don't indent their code could still use the specific legacy end keywords, and burn in the eternal fires of hell.

I'm also beginning to get really adversed to "call", "set", and "local". Verbosity is nice and makes code easy to read, but mindless useless keywords just take effort to maintain in code.

tl;dr:
Collapse JASS:
global integer SomeVal = 42

function Sex takes nothing returns nothing
    if SomeVal == UNIVERSAL_CONSTANT then
        loop
            call SimulateUniverse()
        end
    end
end
__________________
Useful Links:
My Resources:
Good Resources:
Search
Tutorials
Ability Guide

UnitMaxState
BonusMod

AutoIndex
ARGB
TimerUtils


Last edited by Earth-Fury : 08-02-2009 at 03:36 PM.
Earth-Fury is offline   Reply With Quote
Old 08-02-2009, 04:14 PM   #2184
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

I actually like block-specific terminators. It makes it easier to see where you are (eg. sometimes people comment their end braces in C++ with '//end if'). Of course, it would be much better if they were automatically inserted when you started a block.

I totally agree with dumping set, call, and local. You can tell which type of statement it is based on the first identifier! (type -> local, variable -> set, function -> call)
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 08-02-2009, 06:19 PM   #2185
ToukoAozaki
extends net.wc3c.Jasser
 
Join Date: Jun 2008
Posts: 336

Submissions (5)

ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)

Send a message via MSN to ToukoAozaki
Default

Quote:
Originally Posted by Strilanc
I totally agree with dumping set, call, and local. You can tell which type of statement it is based on the first identifier! (type -> local, variable -> set, function -> call)

Let's just make unneeded keywords like globals, local, set, call, etc. optional. The point of making "optional" here is not about breaking backwards compatibility. Heck, "call" and "set" makes me typo very often.
ToukoAozaki is offline   Reply With Quote
Old 08-02-2009, 11:03 PM   #2186
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 191

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by ToukoAozaki
Let's just make unneeded keywords like globals, local, set, call, etc. optional. The point of making "optional" here is not about breaking backwards compatibility. Heck, "call" and "set" makes me typo very often.

for that use cJass? coz it has exactlly that what u need! + defines, i++, i+=2 and such a stuff! lol as you can see ur right coz many of this words or few things like i++ are more faster and readable if the rest of code in readable, if all code is unreadable then local, set, call and all that stuff will make it not readable... however even if its like that vex wont add this coz he said that he is most important user of jasshelper and if he does not like that syntax then no one does... thats how he said it!

so if you want to use this stuff just use cJass! else use vJass....
__________________
Undefined shadow...
Dark_Dragon is offline   Reply With Quote
Old 08-03-2009, 06:44 AM   #2187
BlinkBoy
User
 
BlinkBoy's Avatar


Respected User
 
Join Date: Dec 2003
Posts: 835

Submissions (4)

BlinkBoy has a spectacular aura about (97)BlinkBoy has a spectacular aura about (97)BlinkBoy has a spectacular aura about (97)BlinkBoy has a spectacular aura about (97)

Outstanding Tutorial

Default

Talking about C++.

Is there a macro equivalent in vJASS like:

Code:
#define Thunder 0x000000F6

I think it would be useful for the new hashtables that use integers.
__________________
Tools:
NeoDex - a Gmax and 3ds Max modeling Toolset for Wc3!

Learn to animate! check out my: Basic Animation Tutorial!

Currently working at a sequel to my animation tutorial.
BlinkBoy is offline   Reply With Quote
Old 08-03-2009, 10:10 AM   #2188
Barade
User
 
Barade's Avatar
 
Join Date: May 2006
Posts: 164

Barade is on a distinguished road (14)

Default

Collapse JASS:
call TriggerAddCondition(st__SpellPureEnergy_staticCastAction,Condition( function sa__SpellPureEnergy_staticCastAction))
If I disable the debug mode it seems to work (less code?!).
Attached Images
File Type: png error.png (37.7 KB, 27 views)
__________________
Barade is offline   Reply With Quote
Old 08-04-2009, 07:57 AM   #2189
Vestras
User


Project Member: LoC
 
Join Date: Dec 2007
Posts: 756

Submissions (4)

Vestras will become famous soon enough (40)Vestras will become famous soon enough (40)

Default

Quote:
Originally Posted by BlinkBoy
Talking about C++.

Is there a macro equivalent in vJASS like:

Code:
#define Thunder 0x000000F6

I think it would be useful for the new hashtables that use integers.

It'd be a good idea to do something like this:
Collapse JASS:
define
    void = takes nothing returns nothing
    priv = private
    func = function
    bool = boolean
    // and so on...
enddefine
Vestras is offline   Reply With Quote
Old 08-04-2009, 01:37 PM   #2190
Barade
User
 
Barade's Avatar
 
Join Date: May 2006
Posts: 164

Barade is on a distinguished road (14)

Default

Collapse JASS:
            if (this.getType() == AQuest.typeid) then
                call AQuest(this).setState(state)
            elseif (this.getType() == AQuestItem.typeid) then
                call AQuestItem(this).setState(state)
            else
                call this.setState(state)
            endif
this is an instance of struct AAbstractQuest and setState is stub. Does getType only work for interfaces so how do I call stub methods from parent structs?
It doesn't seem to be called automatically.
__________________
Barade is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 04:25 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services