HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Breaking backwards compatibility next jasshelper update

08-31-2007, 02:28 AM#1
Vexorian
so, after some chat I thought that the next feature in the priority queue would be type safety, it got plenty of advantages for compiling, since that would find plenty of bugs before the pjass' phase (the ideal vJass compiler shouldn't even need PJass) It will also find certain nasty bugs that currently can surive the compile phase, I am sure the ones that use jasshelper frequently had to deal with those hard to find bugs at least once, I know I did.

And it will have the side effect of enabling the typecast operator for handle types and integer (things like integer(GetTriggerUnit()) ) will make sense...

But that's not without bad news, the current weakness in the compiler has been exploited and I think it is currently being exploited, things like :

Collapse JASS:
 local somestruct s
   call SetUnitUserData(u,somestruct.create())
   set s=GetUnitUserData(u)
   set s.k=56

Are possible and in fact were encouraged during the first days of jasshelper, but will break into a syntax error after the next update.

So, get ready and make sure to avoid these things in your current code, might be hard to find, don't be surprised the next update will make you unable to save your map and you'll have to fix plenty of mistakes...

A correct way to do that is:
Collapse JASS:
 local somestruct s
   call SetUnitUserData(u, integer(somestruct.create()) )
   set s= somestruct(GetUnitUserData(u))
   set s.k=56
08-31-2007, 02:24 PM#2
cohadar
I will NOT argue against type safety,
but I have to ask why exactly do we need this when we don't have real polymorphism in structs?
08-31-2007, 02:29 PM#3
moyack
NOOO!!!! I abuse of this feature!!! sigh...

Does This syntax work with v3d??
08-31-2007, 02:47 PM#4
Vexorian
Quote:
Does This syntax work with v3d??
It has worked since ages ago and tried to deprecate the old ways from the readme since it was going to happen.

Quote:
I will NOT argue against type safety,
but I have to ask why exactly do we need this when we don't have real polymorphism in structs?


this currently compiles successfully :
Collapse JASS:
struct b
    integer k
endstruct

struct a
    integer k
endstruct

function err takes nothing returns nothing
 local a q=b.create()
    set a.k=5
endfunction

08-31-2007, 03:32 PM#5
Toadcop
anyway what ever. i have all versions stored ^^ if you will fuck up something i can install the previous versions ;)
08-31-2007, 04:05 PM#6
Vexorian
well, if you are actually doing the things that compile right now but shouldn't compile later your code is the "fucked up" thing.
08-31-2007, 08:18 PM#7
MaD[Lion]
ive always used legal typecasting after the first time typecast came, so im happy :P
08-31-2007, 08:24 PM#8
Toadcop
MaD[Lion] me 2 but who knows... xD it's always better to have a backup copy ;)