Thread overview |
---|
June 26, 2002 Overloading | ||||
---|---|---|---|---|
| ||||
Hello Everybody I have broken my wrist so I will keep this sort.. is there any way overload were the return is the unique section.. Just an example: function long add(int, int) function int add(int, int) main() { long a; int b; a = add(1,1) // this would use the first add b = add(1,1) // this would use the second add } Thanks Ben |
June 26, 2002 Re: Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to ben | Short answer is NO. D does not support overloading. You'd have to do something like long addl(int, int) int addi(int, int) I've been tring to convice Walter to consider explicit overloading using the cast idea Pavel came up with. //For return types float abs(float n) {} //Default int cast(int, long) abs(float n) {} int cast(double) abs(float n) {} //For parameters float abs(float n) {} //Default float abs(float cast(int, long) n) {} float abs(float cast(double) n) {} "ben" <zander@echotech.ca> wrote in message news:afcb1q$158i$1@digitaldaemon.com... > Hello Everybody > > I have broken my wrist so I will keep this sort.. is there any way overload > were the return is the unique section.. Just an example: > > function long add(int, int) > function int add(int, int) > > main() { > long a; > int b; > a = add(1,1) // this would use the first add > b = add(1,1) // this would use the second add > } > > Thanks Ben |
June 26, 2002 Re: Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | "anderson" <anderson@firestar.com.au> wrote in message news:afcgkn$1etm$1@digitaldaemon.com... > Short answer is NO. > D does not support return overloading. You'd have to do something like long addl(int, int) int addi(int, int) > I've been tring to convice Walter to consider explicit overloading using the > cast idea Pavel came up with. > > //For return types > float abs(float n) {} //Default > int cast(int, long) abs(float n) {} > int cast(double) abs(float n) {} > > //For parameters > float abs(float n) {} //Default > float abs(float cast(int, long) n) {} > float abs(float cast(double) n) {} > > > "ben" <zander@echotech.ca> wrote in message news:afcb1q$158i$1@digitaldaemon.com... > > Hello Everybody > > > > I have broken my wrist so I will keep this sort.. is there any way > overload > > were the return is the unique section.. Just an example: > > > > function long add(int, int) > > function int add(int, int) > > > > main() { > > long a; > > int b; > > a = add(1,1) // this would use the first add > > b = add(1,1) // this would use the second add > > } > > > > Thanks Ben > > |
June 27, 2002 Re: Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | Ok thanks. I guess that would lead to alot of problem code, but it could be usefull for math programming, I wish I had an example off hand but I don't, as i have been working on a few porjects i have noticed that I could not do that with c++ and it would have helped me in a few occations.
Thanks Ben
anderson wrote:
>
> "anderson" <anderson@firestar.com.au> wrote in message news:afcgkn$1etm$1@digitaldaemon.com...
>> Short answer is NO.
>>
> D does not support return overloading. You'd have to do something like
>
> long addl(int, int)
> int addi(int, int)
>
>> I've been tring to convice Walter to consider explicit overloading using
> the
>> cast idea Pavel came up with.
>>
>> //For return types
>> float abs(float n) {} //Default
>> int cast(int, long) abs(float n) {}
>> int cast(double) abs(float n) {}
>>
>> //For parameters
>> float abs(float n) {} //Default
>> float abs(float cast(int, long) n) {}
>> float abs(float cast(double) n) {}
>>
>>
>> "ben" <zander@echotech.ca> wrote in message news:afcb1q$158i$1@digitaldaemon.com...
>> > Hello Everybody
>> >
>> > I have broken my wrist so I will keep this sort.. is there any way
>> overload
>> > were the return is the unique section.. Just an example:
>> >
>> > function long add(int, int)
>> > function int add(int, int)
>> >
>> > main() {
>> > long a;
>> > int b;
>> > a = add(1,1) // this would use the first add
>> > b = add(1,1) // this would use the second add
>> > }
>> >
>> > Thanks Ben
>>
>>
|
Copyright © 1999-2021 by the D Language Foundation