by CapnCrunchie on 3/16/22, 12:48 AM with 14 comments
by seniorsassycat on 3/16/22, 6:04 AM
Does the implementation need to repeat the effective union type?
by lloydatkinson on 3/16/22, 11:10 AM
by iron4wine on 3/16/22, 3:55 AM
by gwill on 3/16/22, 2:38 AM
by galaxyLogic on 3/16/22, 2:49 AM
A more readable solution I think is to define multiple functions whose names differ by a suffix that indicates argument type.
Arguments with default values are not really "polymorphic". They juts make it possible to call the function with fewer arguments.
And instead of "polymorphic functions" why not use ES6 classes which are polymorphic by their nature. The class of the recipient determines which method gets executed. There too you can use the approach of defining multiple similar methods whose name differs by a suffix indicating their argument-type.