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

Review the term jump #2

Open
thelink2012 opened this issue Jul 3, 2018 · 1 comment
Open

Review the term jump #2

thelink2012 opened this issue Jul 3, 2018 · 1 comment
Labels
core-spec Core Language Specification revision

Comments

@thelink2012
Copy link
Member

A jump is currently defined as:

A command is said to perform a jump if it changes the flow of control irreversibly.

The definition is sound, but the term is not. A lot of literature uses jump to mean something more broad that what we are looking for. The meaning we pursue is the same as of an instruction that ends a basic block. Examples of usage in the current specification:

[...] The execution of a jump to outside the scope block leaves the lexical scope.

[...] After the set of statements are executed, control is transfered to the end of the IF block, unless execution of the statements resulted in a jump out of the block.

[...] This statement performs a jump to the label specified by identifier if the compare flag of the conditional element holds true. Otherwise, the flow of control is unchanged.

[...]

Even DMA Design used jump to refer to something more broad. On their GTA2script Manual they use jump to refer to the operation performed by a GOSUB.

With the new script system, it’s a lot easier to “jump” to other subroutines in the scriptfile without the messy line numbers. Instead you label a section of commands, and later in the code you “GOSUB” to it. When the subroutine code finishes processing, the game will return to the line after the GOSUB command, effectively ‘inserting’ the code contained at the label.

[...]

NOTE: Subroutines are very powerful, but be careful again with using them too much - they code make your code messy & difficult to follow. As you no longer need linenumbers, jumping about the file shouldn’t be needed quite as much - just insert the new code!

[...]

This is a powerful new command that launches a mission midgame from a different file to the current one. The new file must have a block of commands starting with a MISSIONSTART command & ending in a MISSIONEND command, similar to ‘LEVELSTART … LEVELEND’. When the command is run, the game will load in the file & ‘jump’ to the MISSIONSTART line. Think of it making the script do a ‘GOSUB’ to a label, it just so happens the jump is into a different file, with the label being the filename rather than the actual label… That make sense?

[...]

In this example, the program waits until a ped has reached a given location, incrementing a counter each turn. Functions need not be called as a new thread, they can be ‘jumped to’ and run in sequence instead of parallel. The GOSUB label call acts ‘in sequence’. There is no GOTO, only GOSUB so that the program must return out of the function. Example code:

That manual is quite informal, nevertheless, the term is not good enough. A better one have to exist.

@thelink2012
Copy link
Member Author

LLVM uses terminator instruction but this collides with our definition of terminate and would be a bit confusing with TERMINATE_THIS_SCRIPT.

@thelink2012 thelink2012 added core-spec Core Language Specification revision labels Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-spec Core Language Specification revision
Projects
None yet
Development

No branches or pull requests

1 participant