| 07-15-2006, 12:25 AM | #1 |
The name I've seen that Cooler has a project called JASS++ so I couldn't use that name, also there is no ++ operator in JASS syntax so it wouldn't have any sense. What? All right, let's say we extend JASS by adding a precompiler, and not just things like #include but actual OOP syntax. Why? JASS is already object oriented, but the usage is kind of lame, you either have to use return bug exploiters in your code to make it look terrible or sacrifice speed. And even so it looks really lame. Imagine if we could write things with an OOP syntax that would seem really logical but won't sacrifice speed in game. Example? input:struct pair integer x integer y endstruct function A takes nothing returns nothing local pair tes=new pair() set tes.x=5 set tes.y=4 call BJDebugMsg(I2S(tes.x)) endfunction output:function A takes nothing returns nothing local string tes=GetNewGameCacheKey() call StoreInteger(oop,tes,"0",5) call StoreInteger(oop,tes,"1",4) call BJDebugMsg(I2S(GetStoredInteger(oop,tes,"0"))) endfunction It could be smart, and use locations if the struct only has 2 attributes and even a heap if no string attributes are involved. Defining the syntax The syntax should just be an extension of the over verbose JASS syntax to prevent confusions struct Struct is a good word, I wouldn't use class because this won't have inheritance / polymorphism or anything like that (*too lazy*) The normal jass syntax is thing and endthing to end it that's the reason it would use 2 new keywords struct and endstruct. Attributes Do we need encapsullation? I say no we don't. No private or public distinction should be present, so declaration of attributes should be the same as when declaring things inside a globals block <type> [array] <name> [=initial value] initial value is present so we could save the need of constructors most of the times. Recursive objects Objects or <structs> would always behave like pointers so there is no problem in using the type itself as type of one of its attributes. Constructors The keyword for a constructor would be constructor and would behave like a function. input:struct complexnumber real r real c constructor takes nothing set r=0. set c=0. endconstructor constructor takes real rpart, real cpart set r=rpart set c=rpart endconstructor endstruct output:function e0 takes nothing returns string local string s=GetNewGameCacheKey() call StoreInteger(oop,s,"0",0.) call StoreInteger(oop,s,"1",0.) return s endfunction function e1 takes real rpart, real cpart returns string local string s=GetNewGameCacheKey() call StoreInteger(oop,s,"0",rpart) call StoreInteger(oop,s,"1",cpart) return s endfunction Well that's it for the moment more to come, I have to deal with things like the this pointer and Methods but I am tired of translating code. Notice that the new functions created should use silly names like e0 , e1 and things that seem like the result of the optimizer's name obfuscation, in order to improve speed and to avoid creating functions with names that already exist. That would just be the final result for war3map.j that nobody would read (people would read the source .j files that use "set JASS=JASS+1" syntax. |
| 07-15-2006, 02:16 AM | #2 |
But how do you actually change a language ? The WE won't read it or something... No ? |
| 07-15-2006, 03:01 AM | #3 | |
Quote:
But Vex's idea is a precompiler, so it would parse the code, and then you would put the output into WE...at least that's what I think he meant... |
| 07-15-2006, 03:18 AM | #4 |
Yeah. You write your code in some program that support such rules, which will 'convert' it to regular JASS code, readable for the wc3 engine. |
| 07-15-2006, 03:28 AM | #5 |
Awesome idea. If you made that, Vexorian, I would definitely find ways to use it. I'm forever attached to my C++ structs and classes and general OOP. By the way, I don't think inheritance is as big a deal in Warcraft III. I can't think of too many things that would make use of it, except maybe "defining" a unit and "defining" a unit group. |
| 07-15-2006, 04:32 AM | #6 |
I saw info abaout adding own natives to wc3. This will have same affect and map created by this metod will need modifed wc3 to run |
| 07-15-2006, 04:34 AM | #7 |
Not at all. The stuff you do here will be preprocessed before we even attempts to compile, 'translating' it into your everyday jass code. |
| 07-15-2006, 11:04 AM | #8 |
I dont really see the need. You're sacrificing fast code for conveniance. I'd rather just write gamecache stuff than making structs. But thats just my opinion, im not saying its not a good idea at all, but I prefer fastest posible code. |
| 07-15-2006, 11:35 AM | #9 |
structs result in much faster to type code. I also think that using a heap instead of gamecache would be possible as long as there aren't string attributes. Currently if you use a heap you don't have fields, just indexes which would make your code not as readable as when you use gamecache (although A LOT faster) A precompiler would be able to convert the structs to usage of heaps indexes so set something.x = 4 would be translated to call SetArrayInt(something,0,4) And well we would have other things besides oop syntax. faster:struct dummyinfo effect fx real life endstruct struct spellinfo string fxpath string fxattachmentpoint endstruct function dothingswithdummy takes unit dummy returns nothing //.. code local dummyinfo i=GetDummyInfo(dummy) call DestroyEffect(i.fx) set i.fx=AddSpecialEffectTarget(frozenstrike.fxpath,dummy,frozenstrike.fxattachmentpoint) //... endfunction --- The point of the JASS precompiler I will make is to trash WE actually, well trash WE for JASS development. The precompiler would use pJASS to tell you about syntax errors instead of waiting till WE crashes or disables all of your triggers ... |
| 07-15-2006, 01:11 PM | #10 |
The best solution would be if you could make a modified WE that would process the code on map save/open (into the pseudo-jass equivalent you're proposing) along with syntax highlighting for a completely friendly user environment. Hell, you could include your map optimizer under a publish option even |
| 07-15-2006, 03:45 PM | #11 | |
Quote:
That would quite literally be the most useful feature of the precompiler in my opinion. I hate when you forget to disable a trigger and it crashes or some crap and then you have to fetch it out of the blasted folder and put it back in... It's easily the most annoying thing about jass in the WE. |
| 07-15-2006, 04:15 PM | #12 |
WE and GUI are JASS' biggest enemies Ask anyone, you'll get the same JASS was frustating to learn because of World Editor's bugs and issues when checking the JASS syntax. Also WE doesn't allow you to easily have modular programming. You only edit stuff in the custom text, you don't even have direct control on what function goes first. It is lame. And the best thing to do is to make the JASS code in an external file. Tools like JASS shop pro would be able to edit these external files and show syntax highlighting and check for errors. Then the precompiler should be able to take the source files and make a war3map.j you can simply import in the map. So you could do WE's other things like editing abilities and description and thinks like that. Methods Methods would simply be converted to functions that take an object as argument,. set jass=jass+1:struct dummy unit d effect fx integer abilid method destroy takes nothing returns nothing call DestroyEffect(fx) call UnitRemoveAbility(d,abilid) call RemoveUnit(d) endmethod endstruct function DestDummy takes nothing returns nothing local dummy D= GetHandleInt(GetTriggerUnit(),"dummy") D.destroy() endfunction JASS output:function a2 takes integer this returns nothing call DestroyEffect(GetArrayInt(this,1)) call UnitRemoveAbility(GetArrayInt(this,0),GetArrayInt(this,2)) call RemoveUnit(GetArrayInt(this,0)) endfunction function DestDummy takes nothing returns nothing local integer D= GetHandleInt(GetTriggerUnit(),"dummy") call a2(D) endfunction The name All right everybody knows that set JASS=JASS+1 Is a silly and retarded name, but it is the name for the initial project. The official release should use another name like JASS3 which would be nice since we heard the JASS we are currently using is JASS2 Other features Better strings Heck isn't JASS annoying and lame when compared to JAVA? input:local integer i call BJDebugMsg("This is the number :"+i) output:local integer i call BJDebugMsg("This is the number :"+I2S(i)) For god's sake. input:struct pair integer i integer j method tostring takes nothing returns string return "["+i+","+j+"]" endmethod constructor takes integer a, integer b set i=a set j=b endconstructor endstruct //... local pair T=new pair(3,4) call BJDebugMsg(T) //.. output:function cg takes integer this returns string return "["+I2S(GetArrayInt(this,0))+","+I2S(GetArrayInt(this,1))+"]" endfunction function ch takes integer a, integer b returns integer local integer this=NewArray(2,true) call SetArrayInt(this,0,a) call SetArrayInt(this,0,b) return this endfunction //... local integer T=ch(3,4) call BJDebugMsg(cg(T)) //.. Edit: Yes, I have updated the JASS tag so ti highlights these fantasy keywords |
| 07-15-2006, 05:00 PM | #13 |
It's a great idea and it'd be very useful, all you have to do now is make one and call it pseudo-JASS or something |
| 07-15-2006, 10:48 PM | #14 |
Man, my head is going to explode, i'm still stuck on GUI, I got to quit wc3 moding,.. Even if I almoast have no clue what you said upthere, but i'm going to rep you PS. I just noticed Vex doesn't have 1 of those Respected User thinigies unde his av ;) |
| 07-15-2006, 10:52 PM | #15 |
Mostly because I don't need a label under my avatar to get respect... |
