allwpilib icon indicating copy to clipboard operation
allwpilib copied to clipboard

[command based] add Measure<Time> overload of WaitCommand

Open spacey-sooty opened this issue 6 months ago • 11 comments

Resolves #6382

spacey-sooty avatar Feb 21 '24 14:02 spacey-sooty

Hi really cool that you took my issue, do you think there could be an overload added to the Commands.java class so that the static factory methods can be used with this?

WispySparks avatar Feb 21 '24 16:02 WispySparks

If already, I think having the factory is more important than the constructor overload.

Starlight220 avatar Feb 21 '24 20:02 Starlight220

/format

spacey-sooty avatar Feb 22 '24 02:02 spacey-sooty

/format

spacey-sooty avatar Feb 23 '24 06:02 spacey-sooty

Command::withTimeout should also receive an overload.

Alextopher avatar Feb 24 '24 15:02 Alextopher

/format

spacey-sooty avatar Feb 25 '24 12:02 spacey-sooty

Is a static wait(Measure) overload going to be potentially confusing, as Java Object.wait(long) exists? That's the major reason why it's waitSeconds() instead of wait().

PeterJohnson avatar Feb 25 '24 19:02 PeterJohnson

Dammit Java. It'll be less confusing than the possible wait(double). Object.wait being non-static where the other functions are static should also help here, as it won't be in the same scope (though with static import that could change).

I'm not sure. Dammit Java.

Starlight220 avatar Feb 25 '24 20:02 Starlight220

Idk if I should rename this but right now there is no wait(double) it's waitSeconds(double) purely because my lsp only renamed the overload... image

spacey-sooty avatar Feb 25 '24 23:02 spacey-sooty

What me and Peter are saying is that waitSeconds was not named wait to avoid confusion with Object.wait(long) (which is very much not what our users are looking for), and we're apprehensive about the naming of wait(Time) for the same reason.

The parameter type here makes me a bit less worried (double vs long can also confuse compiler method resolution, whereas Time vs long won't) -- though users looking for the non-unit overload of wait(Time) might look for a wait and not waitSeconds, so idk.

There's also the distinction that the void-returning Object.wait(long) won't fit in the relevant call sites needing a Command to be returned.

Starlight220 avatar Feb 26 '24 06:02 Starlight220

waitTime(t) seems like a good replacement name.

Alextopher avatar Feb 26 '24 08:02 Alextopher