-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
FeatureRequest: Functions #146
Comments
But what would the actual use of functions be? SFM doesn't have variables or return values, pretty sure it can't do math so there's no (good) way to limit recursion. |
I could limit recursion without giving the language math capabilities, but yeah I'm not sure what the use case is |
The use case:
As we can see it has no structure at all Even if i would have them orderd like the functions this code would not look much better This is how the improved version would look like (I used ChatGPT bc i even cant get through that even more (so expect parts to be wrong or from an alternate universe))
|
I don't see how this is different from using code comments tho
|
Sure comments can also do the Job But i think functions would do the job much better (or a combo of both) (my opinion) And when functions would be implemented you could also directly also implement return types (int boolean and void) Which would def step up the sfm game And now you might say but there is no way to store informations like int`s Example
|
You can use the ChatGPT'd output and replace the functions with |
An advantage I see is that it would give each program a sort of "main" or "entry" function. Reading the first loop with the function example I could generally see what the program is supposed to do - as opposed to finding a comment at the start of every loop. I think this feature would be especially nice if there was a quick way to scroll to the function declaration line.
|
perhaps code folding would meet the need until variables and functions are introduced something like
|
When you want to do before you do the function it would be need to also have this
and then you can also fold these. Obv it should also then allow this
(When the functions are implemented they should also be foldable) |
It would be easier to implicitly fold on IF/ELSE/END and DO/END. Or it could be comment style with |
Yes it should also automatically fold on IF/ELSE/END and DO/END
this would be pretty nice |
Comment style for explicit marking would be better since it doesn't actually matter to the program. It's something only for the editor. |
But the avarage player learned that he has a start and a END
or
if the comment is not including start and end this would not be possible
|
Could just let people use
|
Still does not allow for reuse of code but its a start Alternativly you could do it like this
|
Hey DMAN, sup? With that you'll get the math parsing, functions, tables, memory, conditionals, and much more for free, and then you can focus on your feature set. This is just an idea. |
Nah, more fun to do something new |
Why do we need functions?
Bc that would help players make the code more readable
Here is how i would implement functions
For normal players
Functions can only be called in a main function
So it would look like this
So calling a Function in a function would not be possible
Why? Bc otherwise players could create loops which crash the server
Lets say a player knows what he does
Then he can create Advanced Functions which can be called in loops how often the player wants
Maybe also make a gamerule to disallow that (For servers)
This would look like this
Obviously whis would also allow this
The text was updated successfully, but these errors were encountered: