Comments (2)
I am not sure why this would be needed.
A.
UNTIL B {
body.
C.
}.
The above already provides the appropriate functionality.
from kos.
It's not NEEDED, but it's better. Consider that all the major programming languages have some variety of a loop like this. There's a reason for that.
Technically we don't even NEED kosscript at all - just make a direct-to-opcode assembly interpreter and use it to compile direct kRISC code. Why not do that? Because the abstraction is better.
The place where it makes the biggest difference is that it forces the programmer to collect the logic of the loop up into one place in the header. It makes it more readable and more cut-n-paste-able.
The problem is that without it, then in a real loop which doesn't look nice and clean like this:
A.
UNTIL B {
body.
C.
}.
but instead is a messy mixture of loop control statements and other statements, you get this:
D.
E.
A.
UNTIL B {
F.
G.
H.
C.
D.
}.
And then have to slow down and read it very carefully to work out that it's A that's critical to loop initializing and C that's critical to the loop incrementing. The other statements get visually mixed together with them, and it makes code maintenance error-prone.
The FOR syntax allows the programmer to communicate to other programmers "these are the bits that are essential for the loop to iterate properly. All the other statements are about what the loop's effect is meant to be, but these key statements are about how the loop itself is structured."
Trust me, this is very handy. One of the coding practices I use (in languages that have a for loop that works like this) is this: Attempt to envision every WHILE loop as a FOR loop instead. Only in those cases where I find that when I do so that I can't think of anything appropriate to put in the initializer and the incrementer do I then consider it acceptable to go back to writing the loop as a WHILE instead of as "for( ; condition ; )"
And I did say this was an enhancement - for the reason you stated that an alternative does exist in the meantime. That makes it not high priority for now. But I still want it in the list of issues because that's what an issue tracker is for. It's to remember things the project should deal with eventually but you don't have time to go fix them this very instant.
from kos.
Related Issues (20)
- Scope seems to be considered differently 'on board' and 'in Archive' HOT 4
- Resizing terminal repeatedly causes a memory leak [BUG]
- Feature Request: "On Script Error" setting on controller part
- Setting part module field value has no effect for some mods
- docs:"make latexpdf" generates only 19 pages (and they are almost empty) HOT 1
- Some system monospace fonts are not recognized by kOS terminal HOT 2
- Redundancy in compiled form of UNTIL
- Changing the active vessel using `kuniverse` from IVA mode will break the internal camera until the next scene change HOT 4
- KOSVesselModule can populate allInstances dictionary with an ID of 0
- KOSVesselModules has a memory leak problem
- Terminal breaks when something is typed that extends beyond the terminal window
- ship:control:mainthrottle doesn't work unless some other raw control is set [BUG]
- Global vars 'undefined' in local scope after running any program. HOT 6
- Undefined var when checking if the same var is defined HOT 2
- make sure kosnametag doesn't spend time updating
- Get create-release up and running
- Get docs building on github actions
- CI: changelog updating
- Function gets called when checking if a var with same name is defined HOT 2
- Equality comparisons for ELEMENTS and :CREW are broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kos.