HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

more syntax questions

04-07-2009, 03:53 PM#1
Vexorian
Continuing with me being undecided about syntax... I guess everyone already has heard of this module thing. Anyway, there is something I am not sure what to do.

call it module?
It is inspired from ruby where these modules have two purposes, one is to act like namespaces and the other is to allow "mixin inheritance", I am adding just the mixin part of them, so it may not make a lot of sense to call them modules... There's an example of modules at : http://www.wc3c.net/showthread.php?p=1076431 yes, they are mostly textmacros. Will allow things like multiple inheritance and the such.

To call them modules we could justify as they are things you insert into structs, so module could fit, another alternative is "mixin", if anyone has a nice idea, I would appreciate.


text inheritance or children modules?
This is a question, first of all there was the idea to make an implement call that would make the struct's children implement the module:

Collapse JASS:
module myMod
    static method omg takes nothing returns thistype
      local thistype th = thistype.allocate()
           set th.x = 14
     return thistype
    endmethod
endmodule

struct parent
    integer x

     implement myMod in children //something like that...
endstruct

struct child extends parent
    integer y= 34
endstruct

function test takes nothing returns nothing
 local child ch = child.omg()
    call BJDebugMsg(I2S(x)+" , "+I2S(y) ) // 14 , 34
endfunction


There's a slight problem here, and it is that it wouldn't work with the children of the children.

So another idea is to have "text inheritance" this is, a keyword that makes a method to be inherited in a way that the text is copied to child, instead of reused.

Collapse JASS:

struct parent
    integer x
    static text method omg takes nothing returns thistype
      local thistype th = thistype.allocate()
           set th.x = 14
     return thistype
    endmethod
endstruct

struct child extends parent
    integer y= 34
endstruct

function test takes nothing returns nothing
 local child ch = child.omg()
    call BJDebugMsg(I2S(x)+" , "+I2S(y) ) // 14 , 34
endfunction


syntax?
Whether child modules or text inheritance are chosen, the syntax is also another thing I can't decide...

keyword to make a member not available for children?
How about a keyword that makes a member unusable by children even though it is public? (probably requiring super to be able to call it) This allows the children to declare the member again without "member redeclared" errors. It would however not be the same as virtual (stub) cause calling the parent's directly wouldn't call the child's (it could even happen on static methods)
04-07-2009, 08:48 PM#2
grim001
Quote:
Originally Posted by Vexorian
To call them modules we could justify as they are things you insert into structs, so module could fit
Things you plug into structs to gain new functionality, sounds like the definition of a "module" to me. vJass is already too different from other languages to worry about needing the same naming conventions.

Quote:
Originally Posted by Vexorian
So another idea is to have "text inheritance" this is, a keyword that makes a method to be inherited in a way that the text is copied to child, instead of reused.
You can create a module that inserts text methods, so child implements would no longer be needed. Text methods also work with child of child structs, which is important. They make more sense.

Quote:
Originally Posted by Vexorian
keyword to make a member not available for children?How about a keyword that makes a member unusable by children even though it is public?
maybe something like "noinherit" or "nonvirtual," it's a tough one
04-08-2009, 12:45 AM#3
MaD[Lion]
this will be an awesome feature tat i been looking for. Allowing u to make plugins/modules for a system