Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unused public stock variables end up in the p-code #119

Closed
YashasSamaga opened this issue Oct 26, 2016 · 5 comments
Closed

unused public stock variables end up in the p-code #119

YashasSamaga opened this issue Oct 26, 2016 · 5 comments

Comments

@YashasSamaga
Copy link
Member

Stock variables are useful in combination with stock functions. A public variable may be declared as “stock” as well —declaring public variables as “public stock” enables you to declare al public variables that a host application provides in an include file, with only those variables that the script actually uses winding up in the P-code file.

public stock variables are ending up in the P-Code when it shouldn't.

@YashasSamaga YashasSamaga changed the title public stock variables end up in the p-code public stock variables end up in the p-code when unused Oct 26, 2016
@YashasSamaga YashasSamaga changed the title public stock variables end up in the p-code when unused unused public stock variables end up in the p-code Oct 26, 2016
@Y-Less
Copy link
Member

Y-Less commented Oct 26, 2016

#71

@Y-Less
Copy link
Member

Y-Less commented Oct 26, 2016

Looking back, I think the original issue was that unused public variables issued warnings, while unused public functions didn't. However, they could be used, but just not obviously so (a few libraries use and access them exclusively by name). The solution at the time was to make public stock suppress the warning but always keep them; but I think the better solution is to never have the warning in the first place, as with the functions, and use stock to remove them when they aren't explicitly used.

@YashasSamaga
Copy link
Member Author

I have another issue with the scope of public variables. Public functions are accessible throughout the script irrespective of the location where it is declared. But in case of public variables, it is required that they are declared before use.

The PAWN Language Guide says the following,

Public variables behave like global variables,

So I really wonder if it should be labeled as a bug.

@Y-Less
Copy link
Member

Y-Less commented Oct 26, 2016

Global variables behave like that too, so it is accurate.

@YashasSamaga
Copy link
Member Author

#128

@Zeex Zeex closed this as completed in 6a3ab7c Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants