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 16/03/10 00:31
Guest

I'm sorry, ignore the comments in last code I posted... I forgot to delete them
It should have been this
interface IHi {
    bool Hi()
}

struct Hi : IHi {
    private inline bool _Hi() {
        return false
    }

    ~bool Hi() {
        return _Hi()
    }
}

posted at 16/03/10 00:27
Guest

Here's another interesting possibility
interface IHi {
    bool Hi()
}

struct Hi : IHi {
    //would make the below just trigger version
    //without this line below would have both a function and trigger version
    private inline bool _Hi() {
        return false
    }

    ~bool Hi() {
        return _Hi()
    }
}

posted at 16/03/10 00:23
Guest

Oh yes, to auto call an abstract version of a method (if it exists), the ~ should be used.
~Hi()

posted at 16/03/10 00:22
Guest

type ids for structs and classes for each interface they implement and variable number of interface implementations.
interface IHi {}

struct A : IHi {}
So in essence for every struct that extends an interface, increase the preprocessor interface specific counter by one and include a private definition within that struct that is a hard coded value of the interface.
like
<A.IHi.id> = ++IHi.count
interfaces would be triggers like normal, similar to code arrays. I propose there be a trigger version of methods and a regular version.
To get a trigger version with a regular version, syntax should be similar to lambda expressions as in essence each function is anonymous to outside functions, that is, you don't know which one you are calling because the one being called is dependent upon the abstraction of the call.
interface IHi {
    bool Hi()
}

struct Hi : IHi {
    //would make the below just trigger version
    //without this line below would have both a function and trigger version
    bool Hi() {
        return false
    }

    ~bool Hi() {
        return Hi()
    }
}
The above would be similar to how default would work. Look below at my explanation of code arrays to see how the values would be passed in and out. The obvious problem with this is that each value would be passed in by reference, so a possible heap might be necessary for recursive style functions ; \.
I propose you be able to pass in by reference or value in a function. Look at code[] to see how I do pass by reference.
void Hi (int *i) {}
This would allow custom heap memory allocation for passing between methods or the default heap that pumps JASS. For ~ type methods, the custom heap would always be used.
Furthermore, I propose that some functions always be forced to inline. In essence, they'd pretty much be definitions. Obviously, the C inline keyword should be used
inline void Hi() { }
In fact, you could write out definitions this way rather than define if you so wanted as it'd be the same thing.

posted at 15/03/10 23:47
Guest

use : instead of extends for structs
struct B {}

struct Hi : B {}
For extending arrays, use [] instead of array
struct Hi : [] {}
Furthermore, I think that the idea of the current vjass layout for structs is wrong, so scratch all the above.
//this would be struct : []
struct Hi {}

//this would be struct
class Hi {}
When a struct or class extends a handle, the handle should be passed in instead of an integer instance for non-static members.
struct Oo : unit {
    public real operator hp() {
        return GetUnitHp(this)
    }
}
operator keyword should be shed entirely for more C like syntax.
struct Oo : unit {
    public real hp {
        get: return GetUnitHp(this)
        //set:
    }
}
malloc module should be introduced with private definitions specific for the struct or class
struct Oo {
    implement malloc
    }
}

Oo oo = new Oo()
Rather than a create constructor with an allocator, the allocator should be a private definition within the class and the constructor should be standard (auto tied with new).
struct Oo {
    implement malloc

    public Oo() {
        //auto use internal definition, be it from malloc or another style
       //this is auto set to the new instance

      //printf(I2S(this))

      //this is auto returned
    }
}

Oo oo = new Oo()
So, let's say custom allocation is desired for like.. the unit type.
struct Oo : unit {
    define private allocate(this, id, unitid, x, y, face) = {
        this = CreateUnit(id, unitid, x, y, face)
    }
}

//if no constructor present, auto use allocator
Oo oo = new Oo(0, 'hpea', 0, 0, 0)

posted at 15/03/10 21:36
Guest

code[] myCode
void ini() {
    myCode[0] = lambda unit Hi(int i) {printf(I2S(i));return CreateUnit(...)}
    printf(GetUnitName(myCode[0](1)));
}
Turns into-
trigger[] myCode
unit myCode_cjHiUnit
int myCode_cjHiI
bool myCode_CJ_Hi() {
    printf(I2S(myCode_cjHiI))
    myCode_cjHiUnit = CreateUnit(...)
    return false
}
void ini() {
    myCode[0] = CreateTrigger()
    TriggerAddCondition(myCode[0], Condition(function myCode_CJ_Hi))
    myCode_cjHiI = 1
    TriggerEvaluate(myCode[0])
    printf(GetUnitName(myCode_cjHiUnit))
}

#if (true)
#endif
//that will return no such preprocessor //command but..
#if true
#endif

trigger threadLoop = CreateTrigger()
int iterator = 0
int i = 0
//this next line fails too btw
triggercondition loopCode = TriggerAddCondition(Condition(lambda bool() {
loop {
    //and possibly this next line
    exitwhen --i == 0 || --iterator == 0
}

if (i == 0) return true
return false
}))
void Test() {
    i = 100000
    //it'd be nice to do this with cleaner syntax
    whilenot(TriggerEvaluate(threadLoop)) {}
}

int Hi() {
    int a = 5
    if (a == 5) {
        int a = 4
        loop {
            exitwhen --a == 0
        }
        return a
    }
    return a
}

int a = 5
loop {
    int i = 10
    loop {
        exitwhen --i == 0
    }
    exitwhen --a == 0
}

TriggerAddCondition(CreateTrigger(), Condition(~bool() {
    return false
}))
//or
TriggerAddCondition(CreateTrigger(), Condition(lambda bool() {
    return false
}))

posted at 15/03/10 15:13
Guest_t

txt2: we wait for you, ~ADX! & VD//[XGM]

posted at 15/03/10 06:57
Guest

use ~ for lambda expressions instead of lambda. Keep lambda in there as whole word.
TriggerAddCondition(CreateTrigger(), Condition(~bool() {
return false
}))
or
TriggerAddCondition(CreateTrigger(), Condition(lambda bool() {
return false
}))
For some reason, ~ has always seemed to be perfect symbol for lambda to me : P.
I don't really think we'll add ~, but I'll soon add lambda word highlighting =)
~VD

posted at 15/03/10 00:04
N.e.k.i.t

^ after optimizing comment deleted but...

posted at 14/03/10 03:58
Guest

Woops, back here-
triggercondition loopCode = Condition(lambda bool() {
should be
triggercondition loopCode = TriggerAddConditino(Condition(lambda bool() {
lol : P

posted at 13/03/10 18:04
N.e.k.i.t

@Guest, use txt2 markup

posted at 13/03/10 14:43
Guest

Some time helper crashed on syntax errors -_-

posted at 13/03/10 09:52
Guest

On
loop {
//and possibly this next line
exitwhen iterator == 0 || i == 0
}
Should be
--i == 0
||
--iterator == 0
It crossed out the -- and I had backwards : p

posted at 13/03/10 09:49
Guest

Failure

int a = 5
loop {
    int i = 10
    loop {
        exitwhen --i == 0
    }
    exitwhen --a == 0
}
And scoping within blocks with shadowing

int Hi() {
    int a = 5
    if (a == 5) {
        int a = 4
        loop {
            exitwhen --a == 0
        }
        return a
    }
    return a
}
And threaded loops for big stuff-

trigger threadLoop = CreateTrigger()
int iterator = 0
int i = 0

//this next line fails too btw
triggercondition loopCode = Condition(lambda bool() {
    loop {
        //and possibly this next line
        exitwhen --iterator == 0 || --i == 0
    }
    if (i == 0) return true
    return false
}))

void Test() {
    i = 100000
    //it'd be nice to do this with cleaner syntax
    whilenot(TriggerEvaluate(threadLoop)) {}
}

And my previous post...
#if (true)
#endif
that will return no such preprocessor command but..
#if true
#endif
works -.-
I'm writing my code in () to get ready for the next version of cJASS with 1 line if statements! : D
Oh yea.. and something like this would be nice-
foreach(int i in array) {
}
And for loops
Shadowing won't be implemented in near future because of technical difficulties.
Threaded loops are somewhat useless.
And we'll think about foreach.
~VD

posted at 13/03/10 06:04
Guest

bugged
#if (true)
#endif
Fixed
~VD

posted at 11/03/10 07:21
Guest

code arrays-
code[] myCode
myCode = lambda w/e : P
Do it by just storing each one as a trigger and adding a boolexpr and auto return false. For return types, pput it in a global and have the function get the value from global.
here's an example-
code[] myCode
void ini() {
myCode[0] = lambda unit Hi(int i) {printf(I2S(i));
return CreateUnit(...)}
printf(GetUnitName(myCode[0](1)));
}
Turns into-
trigger[] myCode
unit myCode_cjHiUnit
int myCode_cjHiI
bool myCode_CJ_Hi() {
printf(I2S(myCode_cjHiI))
myCode_cjHiUnit = CreateUnit(...)
return false
}
void ini() {
myCode[0] = CreateTrigger()
TriggerAddCondition(myCode[0], Condition(function myCode_CJ_Hi))
myCode_cjHiI = 1
TriggerEvaluate(myCode[0])
printf(GetUnitName(myCode_cjHiUnit))
}
We're not going to implement it in foreseeable future
~VD

posted at 28/02/10 19:49
Dark Dragon

Hi!
my PC just stopped working and i might not be active for some time, i hope to see fully working lambda funcs with new PC xD.
All Best!
\DD

posted at 26/02/10 21:56
Nestharus

Oh, here's another, make a block that'll write to the svn repository using your username or w/e ; D. Also do a browser page for looking through systems on the repository. The only thing the user should see is the documentation for each system : ).

posted at 26/02/10 21:52
Nestharus

Be able to include online files from svn repositories >: o
Like you could browse the repo, find something you like, then include it in your map via including online version. This would mean that systems could be readonly (protected) and will auto update as you'll always include the latest version ; ).
Make it smart, only update it if the versions are dif : P.
It should download to a folder and then include from that folder, but on each save it should check to see if there is a new version ; D.
Your idea is rather interesting and promising but we think it's a bit over top at the moment. We've taken it into consideration so be sure that your words were heard =)
~VD

posted at 24/02/10 20:46
Nestharus

Can you do run once preprocessing commands that run first and run in an order? For example, maybe you want to set up that lexical environment I was talking about and maybe the others want to use that set up? : p
For code manipulation, I think the lexical environment idea is a must = D.
Just parse it into a linked list struct so people can do some serious messing with it. Also allow it to be messed with using preprocessing commands if you don't want to go all out with a plugin. It'd be the best preprocessor ever written, lol.
Plugins would be great if you wanted dif manipulation over doodads or a database or w/e like you said, but for some crazy code manipulation, lexical environment and preprocessing directives that use that environment is even better : ). The plugins could use that environment and the directives in the map could use it ; O.

posted at 24/02/10 20:26
Dark Dragon

@ Sebra
no he needs to do "." syntax only in structs.
why?
coz in structs anonym funcs are static methods!
function interface func takes integer data returns nothing

nothing SleepEx(real secs, func f, integer data) {...}

nothing anonym_12345(integer dat) { msg(I2S(dat)) }

nothing test() {
 // here we dont care since its auto compiled to "func"
 SleepEx(1.5, anonym_12345, 5)
}

struct data {
 static data create() {
 // here data. is a must
 SleepEx(1.5, data.anonym_12346, 5)
}
}

posted at 24/02/10 17:50
Sebra

You will need type control to get it...
function interface func takes integer data returns nothing

nothing SleepEx(real secs, func f, integer data) {...}

nothing anonym_12345(integer dat) { msg(I2S(dat)) }

nothing test() {
 SleepEx(1.5, func.anonym_12345, 5)
}
or am I wrong?

posted at 24/02/10 11:17
Dark Dragon

Hi ADOLF!
here is "true" example:
function interface func takes integer data returns nothing

nothing SleepEx(real secs, func f, integer data) {...}

nothing test() {
 SleepEx(1.5, lambda nothing(integer dat) { msg(I2S(dat)) }, 5)
}
usually that data is some struct pointer ofc...
Regards!
~DD

posted at 23/02/10 22:55
Dark Dragon

K here it is:
function interface void takes nothing returns nothing

function interface math takes real x returns real

nothing test() {
  void v = lambda nothing() {}
  math m = lambda real(real x) { return x*x }

  v.execute()
  msg(R2S(m.evaluate(2)))
}
thanks and greets!
~DD

posted at 23/02/10 22:38
Dark Dragon

Ahh, thanks!
now i understand plugins.
i thought they are asm code... silly me xD
anyway this is usefull, through i dont think it will be for me since i dont know asm nor c++ so well to create new preprocessor...
waiting for "any type" lambda funcs :)
All best!
~DD
What you need to lamblia functions? Please write again.
~ADOLF

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]