HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unexpected: requires TimerUtils, initializer init

09-04-2008, 08:22 AM#1
Vestras
Can't scopes both have requirements and initializers?
09-04-2008, 09:02 AM#2
Vestras
So I cannot put needs/uses/requires in a scope?
09-04-2008, 10:04 AM#3
Vestras
It did :(
09-04-2008, 10:06 AM#4
Strilanc
... then use a library.

The only advantage scopes have over libraries is that they can be nested. Sometimes.
09-04-2008, 10:09 AM#5
Anitarf
If nothing will require your scope then there's no reason to make it a library. Since all libraries are parsed before scopes a scope doesn't need the requires keyword at all.
09-04-2008, 10:44 AM#6
MaD[Lion]
library pwns scope
09-04-2008, 10:50 AM#7
Strilanc
Quote:
Originally Posted by Anitarf
If nothing will require your scope then there's no reason to make it a library. Since all libraries are parsed before scopes a scope doesn't need the requires keyword at all.

I tend to think of it the other way: if your library doesn't need nesting, there's no need to make it a scope.

Plus libraries move the "this triggers requires system X" from the comments into the code, which is a good thing.

Would you care to explain why you consider switching to libraries to be a cost?
09-04-2008, 11:43 AM#8
Vexorian
some people just don't want to use library, mostly because they have many requirements and specifying them is apparently a much bigger effort than calling their functions.

"requires TimerUtils, initializer init"

Even if that was a library it would cause a syntax error, initializer comes before requires and there is no comma separating initializer and requires.
09-04-2008, 12:57 PM#9
Anitarf
Quote:
Originally Posted by Vexorian
some people just don't want to use library, mostly because they have many requirements and specifying them is apparently a much bigger effort than calling their functions.
I use scopes to distinguish spells from systems, and since I list the requirements in the spell's documentation section anyway I don't see how effort has anything to do with this. Personally, I think listing the requirements in the documentation is better anyway, you can make the list more readable by actually making it a multi-line list, you can add in URLs for systems etc, something you can't really do in that single line of the library declaration.
09-04-2008, 01:20 PM#10
Strilanc
Quote:
Originally Posted by Anitarf
I use scopes to distinguish spells from systems, and since I list the requirements in the spell's documentation section anyway I don't see how effort has anything to do with this. Personally, I think listing the requirements in the documentation is better anyway, you can make the list more readable by actually making it a multi-line list, you can add in URLs for systems etc, something you can't really do in that single line of the library declaration.

You can comment the requirements for libraries as well.

The dependency list in code gives much better errors when uses make mistakes, though. "You're missing library X" vs "This line you don't understand calls a function you don't know about that isn't present in the map".

I suppose there's some value if you always use it to distinguish spells ... kindof
09-04-2008, 06:50 PM#11
Vexorian
Quote:
I think listing the requirements in the documentation is better anyway, you can make the list more readable by actually making it a multi-line list, you can add in URLs for systems etc, something you can't really do in that single line of the library declaration.

You can/should do both, think of this: The guy implementing the spell forgot to include one of the required libraries, if you used scope he will get plenty of "undeclared .... or expected a name, etc", if you used a library he will get "Missing library requirement ...."