| 12-17-2009, 05:18 AM | #1 |
Why doesn't it work...? JASS:
struct Parent
struct Child
endstruct
endstructDoesn't work. |
| 12-17-2009, 11:09 AM | #2 |
You can only nest scopes. What are you trying to do? I think what you want to do is extend structs. JASS:struct Parent endstruct struct Child extends Parent endstruct http://www.wc3c.net/vexorian/jasshel...l#extendstruct |
| 12-17-2009, 11:46 AM | #3 |
No, he wants to nest, it's kind of a logical placement, just to show, that those to belong together. It's not possible, because its not necessary, all profits you get with that you can earn by using privaze keyword and an intelligent Namiingconvention ... Next time post in Triggers and Scripts or JH Thread :) Greez |
| 12-17-2009, 06:48 PM | #4 |
Bah. I need to be able to nest structs... I'm trying to be able to do more OOP style programming, doing something like this; call Parent.Child.Method. Is there any kind of work around for that? |
| 12-17-2009, 10:45 PM | #5 |
The work around is not doing it. Composition is not part of vjass. I think that maybe if hell freezes , then melts and then freezes again I will make a good vJass compiler that allows nesting types and structs inside structs, but in jasshelper.exe it won't happen. |
| 12-18-2009, 12:05 AM | #6 |
It may not be exactly what you want. JASS:library test initializer onInit private struct ChildEx method echo takes nothing returns string return I2S(this) endmethod endstruct private struct Parent ChildEx Child static method create takes nothing returns Parent local Parent p = Parent.allocate() set p.Child = Child.create() return p endmethod endstruct private function onInit takes nothing returns nothing call BJDebugMsg(Parent.create().Child.echo()) // Displays 1 call BJDebugMsg(Parent.create().Child.echo()) // Displays 2 call BJDebugMsg(Parent.create().Child.echo()) // Displays 3 endfunction endlibrary |
| 12-18-2009, 02:42 AM | #7 |
Not quite... What I want is this; JASS://library... struct Parent struct Child static method Print takes nothing returns nothing call BJDebugMsg("Hai") endmethod endstruct function Init takes nothing returns nothing call Parent.Child.Print() endfunction //endlibrary... @Vexorian I don't see what's wrong with it. It could really help with keeping code organized. It doesn't really have to be nested classes. You could implement some kind of namespace style "container", which have the same effect (Parent.Child.Method) |
| 12-18-2009, 02:51 AM | #8 |
it is not wrong. It is just something I can't really add to jasshelper.exe's poor compiler ways. So if I ever code an actually good compiler it will allow it. |
| 12-18-2009, 03:08 AM | #9 |
That still would be very simple. JASS:library test initializer onInit private struct ChildEx static method Print takes nothing returns string return "pwnt" endmethod endstruct private struct Parent static ChildEx Child endstruct private function onInit takes nothing returns nothing call BJDebugMsg(Parent.Child.Print()) // Displays pwnt endfunction endlibrary |
| 12-18-2009, 03:36 AM | #10 |
@ Vexorian Ah. @ TriggerHappy Mind explaining exactly how that works? |
| 12-18-2009, 04:23 AM | #11 |
The struct Parent just has a pointer (named Child) to the ChildEx struct. |
| 12-18-2009, 07:39 AM | #12 |
Alright, thanks. I'll try that tomorrow. |
| 12-18-2009, 12:05 PM | #13 |
Or you could use Delegates and use another struct that you use as the child ... |
