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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top