Inheritance in JASS

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Ayanami:
1. So essentially, Inheritance and Interfaces in JASS pretty bad? I mean, it's very limited.

1. What do you mean with "very limited"; what do you want to do but you are unable due to jasshelper's inheritance and interfaces limitations?
 

Dirac

22710180
Reaction score
147
That's slower than a trigger evaluation and you can't still add arguments to it.
Plus code can't be an array
 

Bribe

vJass errors are legion
Reaction score
67
If you create your own force (so it's not an array) it's faster than a trigger evaluation. You also can't evaluate boolexprs in their raw state, unlike code.

Sure there are pros and cons to each but I bet no one would be using boolexpr's if "code array" would work properly.
 

Ayanami

칼리
Reaction score
288
Ayanami:
1. So essentially, Inheritance and Interfaces in JASS pretty bad? I mean, it's very limited.

1. What do you mean with "very limited"; what do you want to do but you are unable due to jasshelper's inheritance and interfaces limitations?

For example, you can't really do Generic Programming. My idea was to treat multiple struct as a single object. But it seems in JASS, it's not really wise to do that. I meant limited in this sense.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Ayanami:
1. For example, you can't really do Generic Programming.
2. My idea was to treat multiple struct as a single object.

1. Generic Programming as in Generic Programming? I don't think generic programming has to do anything with inheritance. It seams to me it's just a compiler "hack" that save you a lot of typing =). So you need a generic max function then your write it once and don't bother with imax, rmax, BigIntmax, etc... Or you need a vector of ints then you do vector<int> or vector of "whatevers" (vector<whatever>) (for C++). Well it seams to me that textmacro can do that pretty easily for vJass: //! runtextmacro max("rmax", "real") and you really don't need vector for vJass cause arrays are really huge (JASS_MAX_ARRAY_SIZE ~= 8K).
Some one might find the "need" for a generic list type but you are probably just better to wrap the type in a struct and implement a list module.
I guess modules are the "remedy" for almost every oop concept there is. It (the problem you want to "solve") can probably always be solved "best" (in terms of efficiency and easy of use/writing) with modules in my opinion. So I guess it always boils down to modules/structs for vJass =).

2. Can you elaborate more on that point? I don't get it. Are you writing about polymorphism?
 

Ayanami

칼리
Reaction score
288
Ayanami:
1. For example, you can't really do Generic Programming.
2. My idea was to treat multiple struct as a single object.

1. Generic Programming as in Generic Programming? I don't think generic programming has to do anything with inheritance. It seams to me it's just a compiler "hack" that save you a lot of typing =). So you need a generic max function then your write it once and don't bother with imax, rmax, BigIntmax, etc... Or you need a vector of ints then you do vector<int> or vector of "whatevers" (vector<whatever>) (for C++). Well it seams to me that textmacro can do that pretty easily for vJass: //! runtextmacro max("rmax", "real") and you really don't need vector for vJass cause arrays are really huge (JASS_MAX_ARRAY_SIZE ~= 8K).
Some one might find the "need" for a generic list type but you are probably just better to wrap the type in a struct and implement a list module.
I guess modules are the "remedy" for almost every oop concept there is.

2. Can you elaborate more on that point? I don't get it.

Well, my idea was to treat multiple struct to one type. For example in Java, every Class extends the class "Object" by default. Thus, every Class can be treated as an Object. I was trying to achieve that by extending each child struct to a single parent struct. Thus, I had to understand how inheritance actually works in JASS to achieve this. But knowing the instance limits, I don't think this is very practical.
 

tooltiperror

Super Moderator
Reaction score
231
Well, seeing as every type is only an integer, why can't you do that? You just have to do some working around your initial idea. You can even do something like a module called Object that packages stuff together. Besides, that type of Abstraction isn't usually needed for JASS.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Ayanami:
1. But knowing the instance limits, I don't think this is very practical.

2. For example in Java, every Class extends the class "Object" by default.

1. I don't think that extending reduces instance limits (C extends B extends A, you can still have 8190 C's) right?

2. You can make your structs/classes extend JObject instead =). OT: I wonder why some libraries prefix their types with a single capital letter (JLabel? QString?!?! any ideas?).

I think it's a good thing that vJass has many options/features and users can do what they please, it probably doesn't always turn out to be "the best" but hey Tim Toady right =)?
 

Ayanami

칼리
Reaction score
288
Well, seeing as every type is only an integer, why can't you do that? You just have to do some working around your initial idea. You can even do something like a module called Object that packages stuff together. Besides, that type of Abstraction isn't usually needed for JASS.

Hmm, well I was planning on doing something that requires Abstraction. Could you elaborate on the module part?

Ayanami:
1. But knowing the instance limits, I don't think this is very practical.

2. For example in Java, every Class extends the class "Object" by default.

1. I don't think that extending reduces instance limits (C extends B extends A, you can still have 8190 C's) right?

2. You can make your structs/classes extend JObject instead =). OT: I wonder why some libraries prefix their types with a single capital letter (JLabel? QString?!?! any ideas?).

I think it's a good thing that vJass has many options/features and users can do what they please, it probably doesn't always turn out to be "the best" but hey Tim Toady right =)?

I read somewhere that it reduces your individual instances. C extends B extends A would have 8190 instances in total. That's what I heard.

Actually, I could use an Interface, right?

JASS:
interface Object
endinterface

struct A extends Object
endstruct

struct B extends Object
endstruct
[/ljass]
 

Dirac

22710180
Reaction score
147
I'm no expert on Java but it really frustrates me that i can't create my own custom allocation methods. (You can't assign integer values to objects)
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Sure you can:

JASS:
interface Object
endinterface

struct A extends Object
endstruct

struct B extends Object
endstruct


Although you can't do:
JASS:
interface I1
endinterface

interface I2
endinterface

struct S extends I1, I2
endstruct


Why would you need this for Jass scripting? I don't know...


Dirac:
1. I'm no expert on Java but it really frustrates me that i can't create my own custom allocation methods. (You can't assign integer values to objects)

1. =). You are writing about java right? How does assigning an integer to an object equates to a custom allocation method? Java is strict about it's allocation schemes with the new TypeName/Constructor thing and sometimes ClassWithStaticAllocationThingy.new() =).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top