allwpilib icon indicating copy to clipboard operation
allwpilib copied to clipboard

[docs] [commands] Disambiguate ProxyCommand and DeferredCommand and deprecate ProxyCommand supplier constructor

Open DeltaDizzy opened this issue 1 year ago • 18 comments

There have been many instances of confusion around the differences between ProxyCommand and DeferredCommand, and while reading the source answers most of these questions it would be better for the documentation to clearly explain the use cases and differences of each. ProxyCommand docs now explicitly state its use case as an escape hatch from automatic command composition requirements. DeferredCommand docs state that it is for scheduling a command at scheduling time instead of binding time.

C++ docs and wpiformat will be done once the java wording and coverage is approved, since it's just a copy over.

Fixes #5244

DeltaDizzy avatar Jan 29 '24 06:01 DeltaDizzy

/format

DeltaDizzy avatar Jan 29 '24 08:01 DeltaDizzy

This PR is blocked on a ProxyCommand section being added to frc-docs.

DeltaDizzy avatar Jan 29 '24 20:01 DeltaDizzy

/format

DeltaDizzy avatar Jan 29 '24 22:01 DeltaDizzy

/format

DeltaDizzy avatar Jan 31 '24 03:01 DeltaDizzy

/format

DeltaDizzy avatar Jan 31 '24 07:01 DeltaDizzy

For what it's worth, the proxy command supplier constructor is very useful in scheduling a command from a SendableChooser, since you can have trigger.onTrue(new ProxyCommand(chooser::get))

anglesideangle avatar Feb 04 '24 23:02 anglesideangle

Yeah, that's a use case that would get cut by this. We should have a factory that sugars combining a SelectCommand and SendableChooser.

Starlight220 avatar Feb 05 '24 05:02 Starlight220

I don't see that as a valid use-case for ProxyCommand - that should be a DeferredCommand, which is the whole point of this change.

Oblarg avatar Feb 05 '24 14:02 Oblarg

DeferredCommand wouldn't work here because command requirements from a SendableChooser need to be evaluated at runtime

anglesideangle avatar Feb 05 '24 14:02 anglesideangle

I don't follow why that needs to be the case, but if you need to escape from the requirement algebra you can use proxy for that, but not for the deferring. It is not really any harder to type proxy(defer(...)).

Oblarg avatar Feb 05 '24 14:02 Oblarg

I think that the point here is that Deferred is for creating a command at runtime, whereas what is needed for choosing autos is something that can choose between multiple existing commands (such as Select).

Starlight220 avatar Feb 05 '24 17:02 Starlight220

I think that the point here is that Deferred is for creating a command at runtime, whereas what is needed for choosing autos is something that can choose between multiple existing commands (such as Select).

I agree with that, but it seems a bit out of scope for this PR. Maybe split the deprecation into another PR which either is blocked on one to add that sugar or adds it itself?

DeltaDizzy avatar Feb 07 '24 21:02 DeltaDizzy

That should definitely be a different PR.

Starlight220 avatar Feb 08 '24 04:02 Starlight220

My question is more three PRs (deprecation blocked on the sugar) or two (deprecation and sugar combined).

DeltaDizzy avatar Feb 08 '24 06:02 DeltaDizzy

The deprecation should stay in this one.

Starlight220 avatar Feb 08 '24 09:02 Starlight220

/format

DeltaDizzy avatar Feb 10 '24 02:02 DeltaDizzy

/format

DeltaDizzy avatar Feb 10 '24 17:02 DeltaDizzy

/format

DeltaDizzy avatar Feb 10 '24 19:02 DeltaDizzy

Please split this into two PRs. We can't merge deprecations mid-season, because too many teams see them as errors that must be fixed, rather than as warnings.

PeterJohnson avatar Mar 11 '24 16:03 PeterJohnson

/format

DeltaDizzy avatar Mar 12 '24 07:03 DeltaDizzy