Skip to content

feat(ParseResults): Alias *PostProcessResult* -> *GetResult* #211

@bartelink

Description

@bartelink

Preamble:

I have used Argu for many years but PostProcessResult always scared me (and I had not seen it organically).

The naming put me off - it sounds like something some metaprogrammer genius would be doing in some esoteric scenario.

In recent times, I actually saw/looked at the tutorial for the first time, and realised it was actually quite useful (I used to do Option.map and think no more of it, but having exceptions be trapped and reported wrt that specific argument is very desirable)

The other issue is that short names matter


Now that there is a GetResult with a fun () -> <default>, it would seem some additional overloads would be useful:

  • GetResult<T>(Thing, fun x -> <map x to T>) : 'T (aka PostProcessResult)
  • TryGetResult<T>(Thing, fun x -> <map x to T>) : 'T option (aka TryPostProcessResult)
  • GetResult<T, U>(Thing, (fun () -> <default Thing : T>), fun x -> <map x to U>) : 'U
  • GetResult<T, U>(Thing, <default Thing: T>, fun x -> <map x to U>) : 'U (if I can only have one, I'd take the preceding one, but its way less parens)

The main questions for me are:

  • does anyone other than me see the point of these extensions? I have real code that would benefit from these a lot...
  • is the current name actually better anyway
  • is Argu just too old.mature to change something fundamental like this?
  • would the overloading cause mess/conflict in real code

I propose to:

  • add the overloads now, possibly as a -rc so it can be road-tested
  • In V7, Obsolete PostProcessResult/TryPostProcessResult (with recommendation to use GetResult/TryGetResult instead)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions