Comments are closed

cJass on the Google Code.
Our BugTracker (recommend to post bugreports and features request there).
Beta tester notes.

all times are GMT +03:00
Latest posts

Pages: 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

posted at 03/04/10 23:42
Guest

Oh yes, I also think that preprocessing should include easy access to all map data (terrain, objects, etc) with an easy to use API similar to the OBjectMerger.

posted at 03/04/10 23:40
Guest

I already think that preprocessing should include-
if, loop, functions, variables, goto, print (prints line to code relative to position), delete (deletes a line from code relative to position), and a code structure in a multi dimensional linked list form for easy editing.

posted at 03/04/10 19:36
Troll-Brain

loop textmacro/defines would be extremely useful for benchmarks, or even to test when a code reach the limit op.
(bored to copy/paste the tested code ...)
Since Vexorian won't implement it for textmacros, maybe you will do it with defines.

posted at 01/04/10 20:09
DarkDragon

yeah i understand ur point guys! it was just a suggestion, so its up to ADOLF to decide "will he and how will he" implement it. basically what i really need are any type anonym funcs, init globals with my custom funcs and static variables...

posted at 01/04/10 17:50
Sebra

unit u[] = { new unit(), new unit(), new unit() }
Becomes assignments, so must be after declarations.
u[0] = u[1] = u[2] = null
What are you think about whis:
a[++i]=b[++i]=c[++i]=func(++i)
The only way to do it right is through the buffer variables, type safety and operator[]= detection.
Thehe will be just an another project for Galaxy.

posted at 01/04/10 07:27
Guest

hm..
nothing test() {
  unit u[] = { new unit(), new unit(), new unit() }
  if (integer i = 0 == 4) {}
  u[0] = u[1] = u[2] = null
  if (i = 7 != 10) {}
}
I've never seen variables set or checked in that manner... I've seen something similar in Lua with comma separated lists of variables being set to a value though.
i[0], i[1], i[2] = null
But when you get into that kind of code, it really lowers readability and no sane programmer ever does that. For example, lists of variables being declared are rarely if ever done in C.
int a, b, c
Now, initializing an array to a set of values like-
int i[] = (1, 2, 3)
That is done much more often, especially in passing in arrays of parameters (variable argument count, like in cmd).
Now things that should be done are obviously things that lend more to C syntax, like new and delete instead of .create and .destroy, things that act more like structs and less like classes, and so on ;O, as well as auto malloc heaps rather than coding it out by scratch every time and ternary operators. From there, could even go up to C++ level to a degree.
With the sized arrays in Galaxy, it should be rather interesting to see what people do = ). Rather than one heap for each and every struct, there can be one heap for the entire map (reduces clutter of global scope). If all data types can be easily converted into integers and back (string as arrays of integers and etc), then it'd be even better =).
Oh well.. I wonder if this project will move to Galaxy some day.

posted at 30/03/10 19:43
Troll-Brain

Maybe you already know it but AdicParser fail with vJass textmacro optional.
Example of code :

posted at 30/03/10 15:59
DarkDragon

Hi!
here are few suggestions which could be implemented after you do what you are currently fixing/implementing...

struct vector {real x, y}

vector MyVec = vector.create()
boolexpr MyFilter = Filter(lambda boolean() {return true})
this vars are placed in InitGlobals() func or directly in main()

nothing test() {
   static boolexpr bx = Filter(lambda boolean() {return false})
}
this is simply global and is as well placed in main() or InitGlobals()

real get_min(real x, real y) { return (x < y)? x : y }

nothing test() {
  unit u[] = { new unit(), new unit(), new unit() }
  if (integer i = 0 == 4) {}
  u[0] = u[1] = u[2] = null
  if (i = 7 != 10) {}
}
simply array init stuff and declaring vars in if/while...
compiled to:
nothing test() {
  unit u[]
  u[0] = new unit()
  u[1] = new unit()
  u[2] = new unit()
  integer i = 0
  if (i == 4) {}
  u[2] = null
  u[1] = null
  u[0] = null
  i = 7
  if (i != 10) {}
}

Regards!
~Dark Dragon

posted at 28/03/10 17:02
Troll-Brain

@Mooglefrooglian
Same result, cJass parser doesn't hande it, since i got a pjass error "unrecognized character #".
Should i attach the parsed_war3map.j/optimized_war3map.j or the whole map ?

posted at 27/03/10 09:49
Guest

I use define all the time instead of #define... the # just translates into white space unless it is applied to a directive that already exists in the language, like the if statement.

posted at 27/03/10 03:11
Mooglefrooglian

Trollbrain, use #define, not define.

posted at 24/03/10 17:41
DarkDragon

Hi!
i replaced my graphic card with my old one until i get new one which should be soon... however i can still work on my project so i was just wondering will "any type" anonym funcs be soon out? or even will they ever be implemented? i dont know but for some reason i think it might not be easy to implement them!
anyway greets guys!

posted at 23/03/10 15:15
Troll-Brain

I use the Table library, and it works, but in a map with several vJass library it gives me a syntax erreor from japi, "syntax error" for "define".
I mean Adic parser doesn't seem the handle it :(

posted at 23/03/10 15:06
Troll-Brain

This works in an empty map (i mean without vJass script) :
[code]define hehe(PLAYER_NUMBER,COMMAND) = {
Str_table[I2S(PLAYER_NUMBER)] = PLAYER_NUMBER
Str_table[COMMAND] = PLAYER_NUMBER
Str_table[(GetPlayerName(Player(PLAYER_NUMBER-1)))] = PLAYER_NUMBER
}[/code]
But fails when i use it in a vJass library, should i attach the map ?

posted at 21/03/10 00:59
YourName

You need a hightlight for the keyword lamba :/

posted at 20/03/10 08:37
Sebra

What's new in 1.4.2.6?

posted at 19/03/10 22:20
Guest

Now if there was a way to solve the { } blocks that are split up across preprocessor directives like definitions and ifs =).
For example, my lambda expression below.

posted at 19/03/10 21:44
Guest

// 1.4.2.6
#if 1&&!(!(blah==blah))||1
integer x = 0x00
#endif

posted at 18/03/10 23:57
Guest

TriggerAddCondition(t, Condition(lambda bool() {
When that's in a #if, throws me an unclosed block statement..
ex
#if DO
    TriggerAddCondition(t, Condition(lambda bool() {
#else
    TriggerAddCondition(t, Condition(lambda bool() {
#endif
    return false
}))

posted at 18/03/10 23:54
Guest

#if !true
#endif
throws incorrect preprocess error or w/e
#if not true
#endif
works
-.-...

posted at 16/03/10 02:56
Guest

On Initialization-
Having initialization done via initializer methods and onInit() seems kind of lame. Why are they in methods to begin with? If they were to be in a block, wouldn't it be better to make them anonymous? I mean... that's what they are right?
So a lambda expression by itself like this-
~void() {
    printf("hi")
}
Should auto run on initialization
Anonymous methods would always take nothing and return nothing... so rather than
~void() { }
You could just shorthand it with-
~{ }
Furthermore, standalone lambda expressions (onInit things) should be able to access stuff within the struct its inside of. For example-
struct T {
    private static string i = 0
    ~{
        printf(i)
        printf(thistype.i)
        T t = new T()
        printf(t.i)
    }
}

posted at 16/03/10 01:31
Guest

Final Analysis-
Building an OO framework off of these concepts without adding any extra code to the map itself would be rather easy = ).
You could inline all of the properties (as they are one liners anyways) and well, convert all of JASS into an OO language : D.
Using my property example-
SetPlayerName(player, "Fred")
printf(GetPlayerName(player))
could be written as
player.name = "fred"
printf(player.name)
and it'd be 0 extra code!

posted at 16/03/10 01:28
Guest

Taking it a step further with properties outside of structs!!
real life : widget {
    get: GetWidgetLife(this)
    set: SetWidgetLife(this, value)
}
Now for anonymous stuff and even properties and so on, you would have to change the function names in the background to reflect what the type the property is for (what it extends, which is either thistype or custom).
This means you could easily do this-
string name : player {
    get: GetPlayerName(this)
    set: SetPlayerName(this, value)
}

string name : unit {
    get: GetUnitName(this)
    set: SetUnitName(this, value)
}

string name : item {
    get: GetItemName(this)
}

posted at 16/03/10 01:22
Guest

A further look on methods extending types-
Remember how structs can extend a type to change what type of value the non-static this arg is?
Well, methods and properties should be able to override that value thus changing the type. Hell, you could even do it with functions, which would allow you to write non-static functions for structs without writing them into the struct!!
void Hi() : unit
turns into
void Hi(unit this) {}
So you could now do
CreateUnit(...).Hi()
You could also do static functions the same was as static methods. In this way, all functions are now like methods (in JASS terms), so the new convention for function casing would be the same as method casing.
Examples of overwriting the this or value args can be found in conquering foreach.
Furthermore, in my foreach examples of get and set, specifically here
get: value.previous
that value should really be this.
get: this.previous
For set, it should take both a this and a value, so it'd have two args-
set: this.hi = value

posted at 16/03/10 01:16
Guest

Conquering foreach
foreach (Test2 test in new Test()) {
}
struct Test2 {
    implement malloc

    //properties and fields should work
    private thistype _next
    public thistype previous

    thistype next {
        get: return _next
        set: _next = value
    }

    bool end {
        get: value == 0
    }

    //just an example, but properties should be able to contain private getters and setters

    int testTest {
        private get: return 0
    }
}

struct Test {
    implement malloc

    private Test2 _first
    private Test2 _last

    public Test2 first {
        get: _first
        private set: _first = value
    }

    public Test2 last {
        get: _last
        set: _last = value
    }

    //extending a handle or struct in a property or method changes the value passed in to the non-static member.
    //for example, this would change from thistype to Test2
    public Test2 next : Test2 {
        get: value.next
    }

    public Test2 previous : Test2 {
        get: value.previous
    }

    public bool end : Test2 {
        get: value.end
    }

    public Test() {
        .first = new Test2()
        .first.next = new Test2()
        .last = new Test2()
        .last.previous = new Test2()
        .last.previous.previous = .first.next
        .first.next.next = .last.previous
    }
}
Now analysis of what this turns into
foreach (Test2 test in new Test()) {
    printf(I2S(int(test)))
}
would be something like (using function unique counters)
//ini, normally just a var set to another var
cj_foreach2_anonVar0 = new Test()

//set to initial value
Test2 cj_foreach2_test = cj_foreach2_anonVar0.first

loop {
    printf(I2S(int(cj_foreach2_test)))
    cj_foreach2_test = cj_foreach2_test.next
    exitwhen cj_foreach2_test.end
}

Pages: 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

[back to top]