You know how we say that non-mandatory, non-file p...
# team-maintainers
j
You know how we say that non-mandatory, non-file parameters should go into modules via
ext.args
? What's a good pattern for handling the situation where EITHER params A+B OR params C+D are mandatory? Are they still all optional things to go in via ext.args? Or do we require them all such that folks are forced to supply empty values in all use cases?
😱 2
m
seems to me that all are optional and all are mandatory. I'd day that makes a good case for being sensible rather than following the rule
👍 1
m
When this happens I say they should be an input. One for A+B and one for C+D and include assertions for them
j
OK, thanks!
s
shared a GIF
j
I am the law
m
I associate that with Judge Dredd.
b
This is what record and enum types are useful for. They allow you to model exactly what the allowed states are
Copy code
enum AB_or_CD {
  AB(A a, B b),
  CD(C c, D d)
}
Then you would supply a single input of type `AB_or_CD`:
Copy code
input:
  ab_or_cd: AB_or_CD

  script:
  if( ab_or_cd instanceof AB(a, b) )
    // use a and b...
  else if( ab_or_cd instanceof CD(c, d) )
    // use c and d...
I intend to support all of this as part of static types
🚀 2
j
So looking forward to that stuff!
🎉 1
💯 1
100 rainbow 1