HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

keyword for "this struct"

04-03-2009, 08:24 PM#1
Vexorian
Err I need this for... err, well it would be nice to have, but I need to think of a good keyword for it.

Let's say the keyword was bubba

Collapse JASS:

struct xxxx
     method orz takes nothing returns bubba
     endmethod

     method aaa takes bubba A, bubba B, bubba C returns nothing
     endmethod

    static bubba array meh

endstruct


Equivalent to:


Collapse JASS:

struct xxxx
     method orz takes nothing returns bubba
     endmethod

     method aaa takes xxxx A, xxxx B, xxxx C returns nothing
     endmethod

    static xxxx array meh

endstruct


Guess the idea is understood.
04-03-2009, 08:49 PM#2
PurplePoot
You could always just use this? More keywords tends to get annoying after a point.
04-03-2009, 08:52 PM#3
Vexorian
The this keyword is already in use by jasshelper, giving two absurdly different actions to the same keyword is probably worse than having more keywords...
04-03-2009, 09:06 PM#4
PurplePoot
self? I'm drawing blanks otherwise.
04-03-2009, 09:17 PM#5
moyack
waht about me??

Collapse JASS:
struct xxxx
     method orz takes nothing returns me
     endmethod

     method aaa takes me A, me B, me C returns nothing
     endmethod

    static me array meh

endstruct
04-03-2009, 09:35 PM#6
peq
I think this is only useful if you want to rename the struct which I think is a job for texteditors and not for tools like jasshelper.
But if you want it use something like "thistype" or "mytype".
04-03-2009, 09:36 PM#7
TEC_Ghost
I vote use "that"
04-03-2009, 09:57 PM#8
akolyt0r
yeah ..i think this feature is totally unneeded ...
some simple search/replace achieves the same..
04-03-2009, 10:09 PM#9
Vexorian
Quote:
I think this is only useful if you want to rename the struct
Nah, it is useful for something else.
04-03-2009, 10:10 PM#10
moyack
it makes the code more readable and faster to write, and this is always valuable.
04-03-2009, 10:15 PM#11
grim001
The keyword should be thistype.

Right now I have to use textmacro constructors in many of my systems, since that's the only way to insert "this struct" and make sure it is treated as the child type (with appropriate default values set) during the constructor. I am assuming this is going to work with constructors, for example:

Collapse JASS:
interface Test
    real x = 0.
    real y = 0.
endinterface

struct Parent extends Test

    static method create takes unit u returns thistype
        local thistype p = thistype.allocate()
            call SetUnitX(u, p.x)
            call SetUnitY(u, p.y)
        return p
    endmethod

endstruct

struct Child extends Parent
    real x = 100.
    real y = 200.
endstruct

function SomeFunc takes unit u returns nothing
    call Child.create(u)
endmethod

Without thistype or a textmacro copy of the constructor for the child struct, the unit would be moved to 0, 0 instead of 100, 200. This is a major problem for certain types of systems, so this is useful for way more than search and replace.
04-03-2009, 10:20 PM#12
Vexorian
textmacros (well, something like that) are the main reason behind this
04-03-2009, 10:21 PM#13
grim001
OK, but will it work with constructors as per the example?

Clarification: No, there will be a different way to solve the above problem, and this is intended for something else
04-06-2009, 04:04 AM#14
Vexorian
Yes, that's right I turned it into a poll
04-06-2009, 07:03 AM#15
Viikuna-
I missvoted "me", but I really think that "thistype" is the best.