• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

xJASS Compiler Survey

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
Please fill out this survey.



1. Which style of syntax do you prefer for the preprocessor? Keep in mind that the preprocessor language will be Lua.

JASS:
// preprocessor decorator
preprocessor function takes nothing
end

preprocessor if (...) then
end

preprocessor while
end

// generic preprocessor block
preprocessor
end

// $ is used as the interpolate operator
// # is never used
set x = $preVar + 5

JASS:
// # a shortcut for preprocessor only***
#function takes nothing
#end

#if (...) then
#end

#while (...) do
#end

#preprocessor
#end

2. Which style of syntax do you prefer for OOP?
JASS:
// scope used as a decorator
scope type a extends integer
endtype

// one liner
type a extends integer

JASS:
type a extends integer

// expand type a into a scope using scope merging
scope a
endscope

JASS:
@scope
type a extends integer
endtype

JASS:
expand type a extends integer
endtype

If none of the above seems good, please recommend another way.

3. Would it be better to stick with the standard JASS access modifiers of just local and nothing or expand them into public, protected, private, internal, and local, where local is an access modifier that is applied to things with a limited lifetime.

4. Would it be good to add ++, --, +=, /=, -=, *=, even though the set keyword makes this somewhat confusing? Example: set i++

5. Which of the following do you prefer for typecasting?
JASS:
(type)var

JASS:
type(var)

6. Should only xJASS be in the language? vJASS has a tradition of supporting many languages in only one grammar. Should xJASS only support xJASS? If this is the case, should a vJASS to xJASS translator be written?

7. To support passing arrays around, the array must be copied to a global array and then the global array must be copied to a local array. This is 8192*2 iterations. Is this feature worth the cost?

8. Should delegates be included as a static type that generates a list of ExecuteFunc?
JASS:
delegate onPre
delegate onInit

// initialize libraries that this library may depend upon
call onPre()

// init code for this library

// initialize libraries this depend on this library
call onInit()

Use case
JASS:
scope A
    delegate preInit
    delegate postInit

    integer unitType = 'hfoo'

    call preInit()
    unit b = CreateUnit(...)
    call postInit()
endscope

scope A
    scope LibName
        delegate preInit
        delegate postInit
    endscope

    private function a takes nothing returns nothing
        call LibName.preInit()
        set unitType = 'hpea'
        call LibName.postInit()
    endfunction

    call preInit.register(function a)
endscope

If not, how should order of initialization with scopes of the same name be done?

9. Assuming delegates are used, should there be a shortcut for handling pre and post events?
JASS:
scope a
    // if init extends nothing, it is automatically called at the start and end
    // of the scope
    initializer init
endscope

scope a
    // shorthand for declaring a variable in a scope
    // if it extends something, it is called at the start/end of every function
    // that extends init
    initializer myLib.init extends init

    private function aa takes nothing returns nothing extends a.init.post
    endfunction
endscope

If the above is done, should delegates still be done, or should this feature only be included? Is the above feature useful and readable?

10. Should internal be by trigger/file, by trigger/file/selected scopes, or by trigger/file/selected scopes/selected symbols? If 3 and 4, what sort of syntax should be used to select a scope for internal? That is, when the internal access modifier is used, it can be accessed by anything else within that scope.

JASS:
scope A
    scope B
        internal function b takes nothing returns nothing
        endfunction
    endscope

    scope C
        call B.b()
    endscope
endscope
 
Last edited:
Level 6
Joined
Jul 30, 2013
Messages
282
Please fill out this survey.

1. Which style of syntax do you prefer for the preprocessor? Keep in mind that the preprocessor language will be Lua.
I prefer the first one definitely. the function with preprocessor decorator.

2. Which style of syntax do you prefer for OOP?
ehm.. kind of cant get myself to quite like any of those

EDIT:
well since you're really defining classes..
why not just (tho this looks a bit like vjass structs i think this really is they way to go..)
JASS:
class MyClass

endlass
if you want sth a bit fancier u can allow passing params to the class block

JASS:
class MyClass(extends=[A,B,C]/*resolve conflicts in member by first one in list wins or sth like that */,allocator=MySuperEfficcientSpecializedAllocator /*42 times better than struct MyClass extends array\n implement Alloc*/, pass_by=PASS_BY_REFERENCE)

endclass

////alternatively

// i kind of like the idea of user defined decorators, both builtin and user defined, allow you to achieve so much without special syntax :)
@extends(A,B,C)
@allocator(MySuperEfficcientSpecializedAllocator) # omit this == use A-s allocator in stead, should provide a default
@pass_by(PASS_BY_REFERENCE) # or @pass_by_reference since theres only 2 possibilities
class Myclass

endclass



3. Would it be better to stick with the standard JASS access modifiers of just local and nothing or expand them into public, protected, private, internal, and local, where local is an access modifier that is applied to things with a limited lifetime.

private/public/(maybe) protected

i do like the idea of keeping as close to JASS2 as possible but.. the only reason there is local is so that u can tell appart variables declared inside /outside of functions easily. it doesnt mavy anything to do with encapsulation. use the terms that are meant for it. + all the vjass guys (99% of your audience) already have muscle memory for public/private..

4. Would it be good to add ++, --, +=, /=, -=, *=, even though the set keyword makes this somewhat confusing? Example: set i++
Well imo the set keyword is the really troublesome part..
id definitely add augmented assignments (val <binary_operator>= val2) == val = val <binary_operator> val2)
i'm a bit on the fence about the pre/post increment/decrement tho. people tend to abuse those horribly and most just think i++ == i +=1 when it really isnt. (++i == i+=1) is generally true.. but most people cant even tell the difference.

i think it may be useful. but i'd recommend not choosing quite yet.


5. Which of the following do you prefer for typecasting?
if all it does is change how the compiler does sth then (type) (C style cast)
but if the cast does something else then id prefer type() (rel: str(an_integer) would give you a string(decimal) representation of the integer in python, notice tho that this is not a true cast, its a function call to the type constructor of string)

so.. what woudl i pick?
hmm.. well.
I2S(), R2S() etc are just screaming for string(anytype) and (string)anytype wouldn't be too helpful (you wouldnt realyl expect a C style cast to actually alter the data structure. so im kind of leaning towards the function like form.
type(var)

for struct types tho what will it do?
will it just act as an operator to bypass type safety and use the underlying integer?
or will there be some hook to do intelligent conversion?
structb =(type) structa would be more elegant for the simple case..
however when i think of say..
NumberStack ns = NumberStack(string)
NumberStack ns = NumberStack(List<Tuple2>)
that is way enticing..
sth like

class NumberStack
create(string s)..
create(List<Tuple2> data)


conclusion: type(v) but please allow it do do more than just bypass type checking and allow me to do what it does. (might need a little bit of thought in to managing object lifetimes.

id consider adding eg. a macro to say u want a local variables destructor called at the end of the function so u would have less chance of forgetting.
im kinda cozy with GC i guess.. cuz most languages i use have good GC facilities.. but sth tells me you might not fancy implementing such sophisticated facilities on top of a language like JASS2.. (not to mention u like speed too much :p )

6. Should only xJASS be in the language? vJASS has a tradition of supporting many languages in only one grammar. Should xJASS only support xJASS? If this is the case, should a vJASS to xJASS translator be written?
only support xJASS in the end but please supply a translator utility that's good. (im rly pissed at how fragile a certain map is atm and i would absolutely love you if i didnt have to maintain so many jass dialects i cant even count em all.. (i think theres even some ZINC in there...)
id prolly be using wurst atm but they lack a good converter so too bad :p )

7. To support passing arrays around, the array must be copied to a global array and then the global array must be copied to a local array. This is 8192*2 iterations. Is this feature worth the cost?
hmm.. i do miss it..
id say, make the size declaration mandatory for arrays. (array[size] or array(size) or "array of SIZE" or sth like that would be ok.. i lean towards the first)
if you know array sizes then the cost can be reduced to the point its acceptable (e.g player array alive_players ) and having the array declare its size also forces people to think of the cost a little more.

--- rant ---
Also we could have a custom Array type: that is basically like a vjass struct with sized array member. then you could have pass by reference semantics which would be ok (u do pass-by-ref with objects anyway don't you?).
the issue would ofc be with native functions.. that expect arrays.. (wait .. ehm.. are there any? i cant think of a single one atm..)

but yeah.. a custom Array class would prolly solve a bunch of the issues. but then we must care when/where/if we allow bare jass arrays (efficciency wise might still want to do that) but then well need utils to convert back/forth between em etc..

--- end-rant ---

8. Should delegates be included as a static type that generates a list of ExecuteFunc?
I'm kind of wary of em since ive never used a language that claims to have delegates..
but from what i can tell they are basically classes with 1 function in them each.. right?

why not just make functions first-class citizens of the language.. will probable not be much more work that a delegate and yet be somewhat more powerful..

or is there something about a delegate's usefulness/nature I've missed? quite possible.. then please enlighten me so i too might drool with you :p
9. Assuming delegates are used, should there be a shortcut for handling pre and post events?


10. Should internal be by trigger/file, by trigger/file/selected scopes, or by trigger/file/selected scopes/selected symbols? If 3 and 4, what sort of syntax should be used to select a scope for internal? That is, when the internal access modifier is used, it can be accessed by anything else within that scope.

never used a language that even had "internal" u sure u need that?

maybe internal(A,B,C) where the function is internal to scopes A B and C. still i cant see myself using that any time soon, feels alot like feature creep..
id say say "no" for now and wait till ppl complain :p
 
Last edited:
1. I prefer option 1 (decorator). I never liked it when languages used too many operators, even if it was faster to type.

2. Option 2 seems to be the most intuitive in my eyes.

3. I like having public, private, and protected. I would personally keep local as it is in a regular JASS context (make the learning curve easier), but it is up to you.

4. I like += *= etc. but not ++ --. And imo, "set i += 1" makes sense intuitively (when you read it out). It is up to you whether you want to include "set"--but imo you should have it on all assignments or on none of them at all (not a mixture/optional syntax).

5. I always thought type(var) looked cleaner in most situations. My credo: when in doubt, see what python uses. Python uses type(var), so I would personally go with that. :p And vJASS uses type(var), so it is an easy shift.

6. I like the idea of xJASS exclusive. It just seems more polished. And if you can get a working translator, go for it. But you can put that on the backburner until the language is fleshed out. vJASS allows for so many weird hacks, so it may be tough to make a good translator. IMO, it would be sufficient to support the translation of the JASS resources on the hive (and maybe some of the staple ones on wc3c). That would make the transition really easy.

7. It is cool to be able to pass arrays, but IMO it is not worth it if it is an expensive operation. It is kinda like having vJASS's option to extend array sizes. It is there for anyone to use, but I never ended up using it because it adds so much overhead. I think I'd prefer just passing classes/wrappers. If you can get a decent implementation of arrays in classes (fixed size), you'd be golden. :)

8 & 9 I need more concrete examples. I can't really tell what the feature would be used for.

10. If you choose to include an internal keyword, I would just do it by trigger/file and be done with it. With good programming, you probably won't need to use internal much. For weirder cases, internal would be there to use.
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
1. Second one, it's shorter.

2. This one:
JASS:
type a extends integer

// expand type a into a scope using scope merging
scope a
endscope

3. Not sure. But if one of them allows you just to share variable between sub scopes within the same parent scope, I will surely vote for an expansion.

I want to suggest "constant" become "final"

4. This one I agree 100% it's going to be good.

5. The first one.

6. Not sure. Supporting another language is not bad IMO.

7. No. Who on earth needs more than 8192? Use hashtable or table then. Even though vJass support more than 8192 array size, I don't recall I have ever used that feature (except in multi array thingy) and haven't seen anybody else used that feature as well.

8 & 9. I'm not experienced with delegate keyword. I read about it in jass manual but I forgot what it's used for.

10. I think it should share between scopes within same parent scope only.
 
Level 6
Joined
Jul 30, 2013
Messages
282
7. No. Who on earth needs more than 8192? Use hashtable or table then. Even though vJass support more than 8192 array size, I don't recall I have ever used that feature (except in multi array thingy) and haven't seen anybody else used that feature as well.

we are NOT talking about array size .. just so were clear.
were talking about if you can do
JASS:
function f takes integer array ints returns integer array
    return ints
endfunction
 
Level 6
Joined
Jul 30, 2013
Messages
282
oh, I see. But I don't recall I need to pass array variable as well.

Strange...I do it all the time.
But ok, maybe the problems you typically solve in JASS don't need it as often as some others.

hmm maybe vjass structs take a way some of the uses too, if you have a struct instance with inner array members you are essentially passing arrays around but just don't think about it much.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Thank you for filling out the survey everyone. Your responses will be included in a paper on the design.

We can discuss the initializer thing on the other thread.

edit
Added one more option to question two. It's my personal favorite.

Please update answers with the fourth option in mind : )

edit
After some deliberation on my part, I realize that option 2 in question 2 is flawed because it changes the definition of a scope based on whether something has been declared something else or not. This is not good programming practice =). The definition and the scope should be together.

Anyways, I'll consider everyone's opinions from the survey when doing xJASS. I know that the OOP bit is a pretty hot issue and we have yet to reach any real consensus on it. However, please keep debate out of this thread, it's meant for purely the survey : (. I'd rather not get the thread cluttered. This just makes it more difficult for me to grab everyone's submissions : ).
 
Last edited:
Level 6
Joined
Jul 30, 2013
Messages
282
sorry.. can't share your enthusiasm.
what im realyl doing is creating a class..
but i need to say that i create a type and then some specia "extends" ?!
it just doesnt click. u can work it out ofc but it is not intuitive.

i must strongly suggest you use either class or the likes.
(i'm tempted to offer some prototypal suggestion as an alternative but i fear the implementation would be a nightmare in JASS2..)

perhaps you could expand why this part is important for you?
type a extends integer
is this like saying the type of the primary key or sth? (you expect to use something other than integer? hmm could be useful i guess.. )

i guess what i'm saying is that for what you want to do.. there has been a hundred good (and a thousand bad..) implementations so perhaps it takes a bit more effort if you want to come up with something even better..

(also i think specifying the primary key type of a struct might be sth you could implement as a decorator, its rarely used afterall and it would save on extra syntax..)
 
Level 9
Joined
Jun 21, 2012
Messages
432
1) Option 1.
2) Option 2.
3) Expand into public, protected, private, internal, and local.
4) Good and useful.
5) type(var).
6) I'm here undecided. But I would say it would be good to have support vjass.
7) Maybe yes maybe not. (for wc3 I would say no) but to innovate would be good to include this feature.
8) I did not understand very well, but I say if xD.
9) The same i say above.
10) Not sure here.
 
Status
Not open for further replies.
Top