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

Loop problems #4

Closed
palfrey opened this issue Jul 22, 2018 · 5 comments
Closed

Loop problems #4

palfrey opened this issue Jul 22, 2018 · 5 comments

Comments

@palfrey
Copy link
Contributor

palfrey commented Jul 22, 2018

Loop examples included in the README:

Tommy was a dancer
While Tommy ain't nothing
Shout it
Knock it down
And around we go

and

Modulus takes Number and Divisor
While Number is higher than Divisor
Take Divisor from Number
Give back Number

Couple of problems:

  • Around we go appears to be the "multi-line loop" statement, but that's not documented.
  • There's no indication about whether a while loop is multi-line or one block. So, the first example above just has two blocks, as the And around we go is one block with Knock it down but Shout it is also another block. OTOH the second example has no Around we go but seems to just implicitly treat the Take Divisor from Number as a single-block while loop?

Thoughts?

@ep12
Copy link

ep12 commented Jul 22, 2018

Give back Number seems to be the end of the function definition. This is great to force developers to return something. Some bugs come from ifs without else, so this would make those bugs very rare.
I guess Around we go is the end of a block like }, end or similar. This would mean that loops are block statements. This is great for the compatibility with python. I think it could be possible to write a performance-focussed tokeniser and lexer that uses python's AST module for fast interpreted rockstar execution.

@wolfgang42
Copy link
Contributor

There seems to be a lot of confusion around how blocks work, and different types of code blocks seem to have completely different syntaxes.

  • For functions:

    A blank line denotes the end of a function body.
    Functions in Rockstar always have a return value, indicated by the Give back keyword.

  • For loops, the docs don't say explicitly but around we go and end appear to end a block. However, the Modulus/Midnight function in the example doesn't have either, so I guess the give back/end of function terminate the loop?

  • Conditionals appear to require And before subsequent statements to keep them in the block. This isn't documented, but the TODO section says:

    I'm not sold on the idea of continuation prefixes for block syntax - for starters it won't let you implement nested blocks.

@young-steveo
Copy link
Contributor

young-steveo commented Aug 1, 2018

From what I can tell it now looks like \n\n ends blocks and functions, and Around we go has been removed, so does this resolve this issue?

@cwfitzgerald
Copy link
Collaborator

I would agree. +1 to closing this.

@palfrey
Copy link
Contributor Author

palfrey commented Aug 1, 2018

Agreed

@palfrey palfrey closed this as completed Aug 1, 2018
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

5 participants