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

Variable Naming with Variables #78

Open
omnit3a opened this issue Jun 13, 2022 · 2 comments
Open

Variable Naming with Variables #78

omnit3a opened this issue Jun 13, 2022 · 2 comments

Comments

@omnit3a
Copy link
Contributor

omnit3a commented Jun 13, 2022

I'm not sure how possible this is, as I'm not aware if your able to do this in java, but something that I think could be useful is the ability to pass a variable as the name for another variable. For example, in pseudo-code:
string name = "intVariable";
int name.content = 10;
this would create an integer variable with the name intVariable
let me know what you think

@MH15
Copy link
Collaborator

MH15 commented Jun 21, 2022

Very interesting idea especially for templating/macros. Remember we compile to the JVM not to Java code so anything is possible but it could require storing extra data. What would a use case of this be?

@omnit3a
Copy link
Contributor Author

omnit3a commented Jun 22, 2022

Well, It could be used to introduce some basic object oriented features. For example, say you've defined a struct Human,
this struct is something like this (in pseudocode):
struct Human{ int xPos, int yPos, int ID }
and you're making a game where you're generating a village full of NPCs that use the Human Struct. You could define 20 different Human structs, or you could make a function that creates 20 different Human structs for you. Or, say you don't know how many NPCs are going to be in the village (it's determined by RNG, for example), you could make a function that generates a random amount of NPCs

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