Nivekk / KOS

Fully programmable autopilot mod for KSP.
Other
80 stars 30 forks source link

Return 0 if vessel is on escape trajectory. Since KSP recalcs the orbit ... #253

Open a1270 opened 10 years ago

a1270 commented 10 years ago

...constantly it returns random results during escape. Somewhat address #248. Probably need to work about a policy on return values. I have currently been doing "None" for strings and 0 for numbers. I'll continue down that route until told otherwise.

Dunbaratu commented 10 years ago

For the idea of what to return when the answer is nonsensical I think what I'd prefer is a way that KOS script can check against NULL, and then you can return NULL for all such scenarios and it makes more logical sense that way.

if ENCOUNTER = NULL { print "no encounter coming". }.
if APOAPSIS = NULL { print "no apoapsis.  escape trajectory?".}.
if TARGET = NULL { print "no target selected.".}.

That would provide one generic way to do it that the user always knows works, and also would solve the type checking issue.as NULL is the one thing you would always be able to check against no matter what the object's type is.

baloan commented 10 years ago

I don't like "NULL" as its origin is deeply rooted in pointer-using programming languages. kOS script is much more high-level (like BASIC). "None" as originally chosen makes more sense to me. As a convenience feature we might add None to match "None" (string) in comparisons (like when body is compared to Kerbin or Mun) .

Dunbaratu commented 10 years ago

I frankly don't care what it's called (and languages that the safer concept of references instead of calling them pointers still ALSO use NULL or NIL ).

But what I'm talking about here is a way to say 'is this value meaningful right now or is it a dummy?" that works universally regardless of what type of thing is is. "None" only works with code that is expecting a string. And the number zero only works for numbers for which zero wouldn't also be a valid meaningful value.

If you don't want to call it NULL and want to call it None instead I don't care. It's the same concept either way.

JoCRaM commented 10 years ago

Is it random? I dislike discarding data just because we don't quite understand it. Are you sure you're not discarding periapsis before we've reached it (e.g. a slingshot)?