On 08/01/2021 13:39, Björn Lundin wrote:
> Den 2021-01-06 kl. 03:17, skrev Eli the Bearded:
>> In comp.sys.raspberry-pi, Charlie Gibbs wrote:
>>> On 2021-01-05, Martin Gregorie wrote:
>>>> Its very useful indeed in Java: its often helpful to use the same name
>>>> with different parameter lists for constructors and also for methods
>>>> that
>>>> all do similar jobs, e.g for outputting values from a class its helpful
>>>> to use the same method name, with different parameter lists say:
>>>>
>>>> getValue(String caption, int value);
>>>> getValue(String caption, double value);
>>>> getValue(String caption, boolean value);
>>
>> Java gets that from C++ doesn't it?
>>
>>> I find it easier to just cast "value" to a consistent type.
>>> But then, I'm a hidebound C weenie...
>>
>> Use a union type with an enum for which value in the value is
>> the proper one. That can easily expand to new types that are not
>> easily cast.
>>
>
> easy ?
>
>
>
> How someone can object to the ease of overloading is just beyond me.
>
>
It's very simple. It makes things that behave very differently look
exactly the same.
which is a recipe for disaster
--
“But what a weak barrier is truth when it stands in the way of an
hypothesis!”
Mary Wollstonecraft
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|