• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Previous declaration

Status
Not open for further replies.
Level 8
Joined
Jul 14, 2010
Messages
235
After I imported http://www.hiveworkshop.com/forums/...-127274/?prev=search=man%20eating&d=list&r=20 I got this error:

193808-albums3934-picture46314.jpg


A map can't have two sentences that look the same? These strange annoying errors pop up very often, please make me understand..
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Yes it can have two sentences which are alike, but a map can't have two functions or whatever that have the same name.

If that function is not in a scope and you already have a function called "Init", then of course it fails (if you call function Init and there are two of them, which one to call?)
Solution: put scope (Name) / endscope around the function.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Its a name space collision. To improve consistancy and performance you can only declare a function name once. The reason for this is that if multiple functions with the same name exist, there would need to be some way of handling it which could be unintentional (code bugs as it might not support that behaviour) or hard to compute (slow map load time as extra compile processes need to be run). Blizzard went for simply maiking it illegal to perform (will not compile).

What they could have done instead but sadly did not...
Overload, like java it could identify functions by both name and the parameters they use.
Combine, fuse both functions with the same name into a single function or call both functions with the same name consequitivly (would need overload support or illegal to use different function signatures).
Overwrite, from that point on the function name will refer to different code so that the orignal decleration is no longer accessible.

Overall I like it though as it makes sure you really are calling what you want to call. Overloading or other methods of permitting it could cause bugs where the incorrect code is called. Ofcourse Vjass scope constructs do help make code more manageable.
 
Level 8
Joined
Jul 14, 2010
Messages
235
ah, thats pretty logical :p I just didnt know what the sentence said at first.
But changing the function name to PlantInit and changing: "scope Plant initializer Init" to "scope Plant initializer PlantInit" worked fine

This will probably happen with more spells, so thanks a lot for your help!
 
Status
Not open for further replies.
Top