Zinc

Viikuna

No Marlo no game.
Reaction score
265
Let's say you have a struct that doesn't use .allocate in its create method, but maybe uses a unit id from an indexing system for the struct id.

How would you allow users to declare struct members with initial values? :)

But I'm not getting my hopes up for this.


Doesnt this work?
JASS:

struct A

static method create takes unit u returns A
    return A( GetUnitId( u ) )
endmethod

endstruct

function asd takes nothing returns nothing
   local A a=A.create(GetTriggerUnit())
endfunction


Or this:
JASS:
function SetUnitId takes unit u returns nothing
   call SetUnitUserData(u,A.create())
endfunction


edit. Or did I completely missunderstood you?

edit. Oh yea, new stuff. Damn. I dont even know what Im talking anymore.
 

Vexorian

Why no custom sig?
Reaction score
187
Let's say you have a struct that doesn't use .allocate in its create method, but maybe uses a unit id from an indexing system for the struct id.

How would you allow users to declare struct members with initial values? :)

But I'm not getting my hopes up for this.
Something like array structs get an allocate method that takes an index integer and assigns stuff? I think that's possible, somehow I thought it was better to make the structname[] do it automatically only when the index was not initialized before, but maybe that's less useful (certainly more complicated to add to jasshelper and adds slowdowns)

Though maybe that would deserve another name.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Call it whatever you want. As long as it assigns the "default" values to the struct index provided.

Just make it manual. Array structs are typically used for things like typecasting a unit index to a struct, so it will need to be reinitialised manually, or by some system at some point.

It would be great to have the same method for non-array structs also - since we do not necessarily use the allocator - helps provide sane interfaces to end users once again (or else what does it mean to specify default values for a struct that doesn't use .allocate()?).

One way to do this would be to overload the allocate method to take an integer if you wish to just assign default values to an id. So:
JASS:
local thistype this = thistype.allocate() // normal
local thistype this = thistype.allocate(5) // forces initialising 5 and returning it, doesn't touch stack

All compile time magic, but maybe it is indeed better to have [LJASS]thistype(5).restoreDefaults()[/LJASS] or something.

Inheritance from array structs would be nice also, don't see why not. Maybe I'm missing something there.

This is all very good stuff.
 

grim001_

New Member
Reaction score
6
JASS:
local thistype this = thistype.allocate(5) // forces initialising 5


Yes, this would be cool, I've requested it before. When you have unit indexing, it saves some array lookups if you can just typecast UnitUserData straight into the needed struct type, versus having to look up a struct attached to the unit.

I'm sure there are other uses for picking specific allocate IDs, and it would be nice to be able to initialize default values in those cases...
 

Nestharus

o-o
Reaction score
84
Actually, I tried zinc with cJASS on.

cJASS does not work at all if you try to write in zinc.

I expect that there will be an update.

A combination of regular C Syntax + Zinc is probably a very good thing ^_^.

cJASS will get rid of the horrible Zinc syntax and just make it plain C.. like it should be

Zinc will get rid of horrible vJASS errors =P.

But why not just fix syntax on vJASS.... and keep JASS syntax on it and let cJASS worry about extra syntax.

/gr


Oh yes, and from what I know allocate still does not inline...

Also you cannot make functions always inline, but cJASS definitions you can, but can't be public.

Also libraries still have terrible _ syntax, even in Zinc!
 

Vexorian

Why no custom sig?
Reaction score
187
I can't think a case of array struct inheritance that can't be replaced with an array struct delegate.

JASS:
struct a extends array
endstruct

struct b extends array
     private delegate a par = this //when it works, it works
endstruct


--
Zinc does not use _ for libraries...
Also you cannot make functions always inline,
You mean kids are not going to be able to make all functions inline for absolute no reason? That's a tragedy!

like it should be
Go to hell.
 

Nestharus

o-o
Reaction score
84
That also means that programmers that right 2 lines of code in a function that should be super fast can't force it to inline and instead have to write two functions that are inlined and have those people call both each time.
 

Romek

Super Moderator
Reaction score
963
Complaining about a better syntax because it won't make a 2-liner inline. Oh noes. :(

Vex has a point; why would you need to inline a function like that? 'Super fast'?
If you tell me that you can tell the difference when there's an extra function call, you're lying.
 

Vexorian

Why no custom sig?
Reaction score
187
Complaining about a better syntax because it won't make a 2-liner inline. Oh noes. :(

Vex has a point; why would you need to inline a function like that? 'Super fast'?
If you tell me that you can tell the difference when there's an extra function call, you're lying.
One of the reasons I made textmacros so ugly and I didn't add defines or anything like that to vJass and Zinc is that I knew that doing so would have that effect on people. Even now, I kinda regret textmacros, sure even I used them, but I sometimes think their contribution to some convenience when typing a long function is shadowed by the rather harmful inconvenience they cause when somebody wants you to use his textmacros for "speed".


In part it is my fault, I had a phase in which I worried way too much about speed, and I think I started that whole function call hysteria... With time I learned many stuff, but right now I keep getting this strange feeling that in many cases I keep fighting with the previous version of me that didn't get it. Jass is not better than GUI because you can avoid the extra function calls from BJ, but because it has functions... and getting rid of this true strength just to avoid the extra function call is lame... Jass is a very slow language, it is itself the bottleneck and avoiding a function call is not going to improve things in a noticeable way.

This is one of the reasons I like the idea behind cJASS, people may now choose to use defines in their code, but in a way that makes it not my problem anymore. I do wish it was more of a language fork than a backdoor mix-up though...

cJASS defines can be a powerful tool when used correctly, but honestly very few people can use them correctly , and most people would just grab the chance to turn it into a problem rather than a solution. I think I've only seen weaaddar using them correctly so far... I would have given them a try but it is syntax is designed in a way that it is NewGen(and therefore windows) - only...
 

Trollvottel

never aging title
Reaction score
262
oh, talking about delegates:


I would like it if this was possible:

JASS:

struct test
 delegate string t = ""
endstruct

...

set test = test + "blah"
 

Vexorian

Why no custom sig?
Reaction score
187
hmnn.

It is actually not impossible, but how about no? I've been thinking that instead we could use something like Java's .toString() method that is virtual to every struct?
 

Nestharus

o-o
Reaction score
84
Vex has a point; why would you need to inline a function like that? 'Super fast'?
If you tell me that you can tell the difference when there's an extra function call, you're lying.

I do notice the speed difference Romek... you don't know this, but games I design are very large scale... what this means is that I need every possible resource and it needs to be tight, efficient, and VERY maintainable. Because they are so large scale, the inside things (lists etc) have to be EXTREMELY extensible, otherwise all the maintainability dies.

Saying that, eh, in most cases this isn't going to matter, doesn't make it not a flaw. It's still a flaw in the design and should be fixed -.-, or I'll just wait for cJASS to make public defines ;\.

I designed something like List Optimum Speed because nobody seemed to care about that flaw but me. As a result, it's population is 2x faster than every other struct implemented list. Why? It's those extra function calls nobody seems to care about that I got rid of in mine.


If you're going to keep saying, we don't care about those flaws, then your resources are going to end up getting disregarded when someone comes along that does care about them and makes a resource that does the exact same thing as yours, but does it faster. Why on earth would someone use the slower version?


In essence, you fix it or someone else will. Look at cJASS. Vexorian refuses to implement this stuff, so someone else is coming along that will. Do you know what the cJASS compiler says while it's compiling?

Killing Vexorian

Do you know why? Because people keep coming along and saying, this is messed up, fix it. One of those people ended up being someone like I described. Vexorian refuses to fix it or implement it, so that other person is going to. He also works off of vJASS so that people's code won't break. I personally think he should just compile to straight JASS and let vJASS do its thing, but that's me =p. If he's going to say something like Killing Vexorian but go around and use a resource made by Vexorian, then that to me is screwy. If I were Vexorian, I would purposefully try to break that resource in any way I could (try to make sure cJASS fails) until he either took out the message or stopped leeching off of a supposed "bad resource" by a supposed "bad designer."
 

Vexorian

Why no custom sig?
Reaction score
187
I designed something like List Optimum Speed because nobody seemed to care about that flaw but me. As a result, it's population is 2x faster than every other struct implemented list. Why? It's those extra function calls nobody seems to care about that I got rid of in mine.
Factors and benchmarks are irrelevant. Only "hard core" Jassers care about these things. The most popular map in wc3 did completely fine using only function calls and gamecache... It's after all been ages since the old times in which we didn't even know about memory lieaks, most things were in GUI and everybody was running a pentium III.. Beyond those things, speed does not really matter as much. A factor alone says nothing, 2x faster is not going to matter if the version that is only 1/2 x as fast is fast enough and also makes things easier on the user.

This may be far-fetched, but ... Maybe, just maybe... if mappers would stop caring of finding a faster system once their systems work perfectly, they wouldn't lose as much time switching systems and they would be able to spend this time on... making their map fun...



If you're going to keep saying, we don't care about those flaws, then your resources are going to end up getting disregarded when someone comes along that does care about them and makes a resource that does the exact same thing as yours, but does it faster. Why on earth would someone use the slower version?
:D :D :D :D I take it this means your story about that 2x fast struct list finishes with everyone moving on to use it...

In essence, you fix it or someone else will. Look at cJASS. Vexorian refuses to implement this stuff, so someone else is coming along that will. Do you know what the cJASS compiler says while it's compiling?
And honestly, I wish more people would do that. It is tiresome having to read all those feature requests and insistence on vJass features that I would really, really hate to implement. It is impossible to make everyone happy with a single language. cJass saves me a lot of time and annoyance.


cJass defines are private-only?

If I were Vexorian, I would purposefully try to break that resource in any way I could (try to make sure cJASS fails) until he either took out the message or stopped leeching off of a supposed "bad resource" by a supposed "bad designer."
That's one of the reasons you are not Vexorian.

Anyway, this discussion is about Zinc and I'll appreciate we kept that topic.
 

the Immortal

I know, I know...
Reaction score
51
It's a nice work (language) which I'll probably begin using at some point, as I really prefer less-verbose languages (and that idea of mJass was pretty nice actually =P) and out of wc3-moddiing am coding in cpp. A language with similar (if not same) syntax is really welcome as I often find myself writing semicolons or skipping 'call's/'set's for ex.

So, let's get on the point:

1) As I feel it won't be accepted as a standard and thus systems coded in it won't be accepted (though it's essentially the same compiler and the end-user /mapper/ doesn't have to install another preprocessor for it) I'd like to know if it's possible (time-wise and so) for you to write a conversion util for Zinc -> vJass.. or give me (or whoever wants) thumbs up to write one on their own when I have more time. Tw people will actually able to write in (and use in their maps) w/e language they want (Zinc.. maybe cJass?) while the whole code could easily be converted to the community standard (vJass) if they wish to showcase/contribute their work.

2) Cpp similarities. The reason am not using cJass is exactly this. That it has too many differences with C (excluding function naming differences ofc) and is somehow like learning a new language. That I liked in Zinc. Semicolons, loops and such. But still that return syntax for example buggers me ;p (the 'for' one too, but it's not a big deal doing it with 'while'-s). As I see nothing wrong with nothing Foo() or even switching it to void Foo() (yes, I read your stance on this but still!.. asking you to reconsider it)

3) Deny it or not, to most of people it'd look as Zinc is made to directly compete with cJASS (mostly for the fact it was released when cJass was getting more n more popular). I'm not one of those 'most'. I don't care at all. Just pointing it out.

But overally I like it. And once there's a stance on TH if it'd be allowed to post resources written in it (or a converter is made) I'd most probably begin using it.

ps. Yeah, I do realise for 2) that Zinc Is Not C.. but still! :Р
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
The new jasshelper caused some trouble on structs. It keeps tell me to add .evaluate(). I followed the instruction by adding [autodevaluate], but it is still same.
 
Reaction score
91
> I followed the instruction by adding [autodevaluate], but it is still same.
Same, it gives me problems in PUI_PROPERTY textmacros but this isn't the right place to report...
 

Vexorian

Why no custom sig?
Reaction score
187
hmnn, It is not [autodevaluate] It is [automethodevaluate]
Where is the jasshelper.conf file you are editing located?
I think I am going to switch it so that by default it allows these methods. This goes to show I can't do much fixes to vJass without keeping the backwards compatibility.

othing Foo() or even switching it to void Foo() (yes, I read your stance on this but still!.. asking you to reconsider it)
  • I think type boo() is not good looking.
  • It is incompatible with the code value syntax.
  • Methods and function declaration would be ambiguous.
  • It is horrible.
  • I am not going to change this. (I actually love the ->, but it is also already too late for such changes).

3) Deny it or not, to most of people it'd look as Zinc is made to directly compete with cJASS (mostly for the fact it was released when cJass was getting more n more popular). I'm not one of those 'most'. I don't care at all. Just pointing it out.
I really, really, have no intention to have people that are really into cJass right now move back to my stuff. It is best that they don't. If I intended to compete with cJass I would add defines and void and other incredibly lame feature like that...

1) As I feel it won't be accepted as a standard and thus systems coded in it won't be accepted (though it's essentially the same compiler and the end-user /mapper/ doesn't have to install another preprocessor for it) I'd like to know if it's possible (time-wise and so) for you to write a conversion util for Zinc -> vJass.. or give me (or whoever wants) thumbs up to write one on their own when I have more time. Tw people will actually able to write in (and use in their maps) w/e language they want (Zinc.. maybe cJass?) while the whole code could easily be converted to the community standard (vJass) if they wish to showcase/contribute their work.

1. The code that compiles Zinc code is a separate unit, and I think it would be easy for me to add a --zinc parameter that only does the zinc stuff on a single .zn file. It is possible and easy

I was thinking of doing that (no, not a whole cjASS compiler, damnit. Just zinc) . But I am not sure if it is going to be benign to do such conversor. The zinc->vJass conversion gets rid of comments and that sort of stuff, so I think the Zinc code would be far more readable than the converted to vJass code even to someone that knows only vJass.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top