[Wish] Functional Overloading

Status
Not open for further replies.

Jost aus Soest

Active Member
Licensed User
Longtime User
It would be very useful to have the concept of (functional) overloading also in b4a.

Example for a sub, that handles different datatypes in a different way:
B4X:
Sub MyLog(i As Int)
  Log("Int: " & i)
End Sub

Sub MyLog(f As Float)
  Log("Float: " & f)
End Sub

'...

Sub MyLog(a() As Object)

  Dim i As Long

  Log("Array: [")
  For i = 0 To a.Length - 1
    MyLog(a(i))
    Log(", ")
  Next'i
  Log("]")

End Sub

Example for a sub with optional parameter:
B4X:
Sub InStr(str As String, pattern As String, iStart As Int) As Int
  'Search a substring, starting at iStart:
  '...
End Sub

Sub InStr(str As String, pattern As String) As Int
  'Search a substring, starting left as default:
  Return InStr(str, pattern, 0)
End Sub

As Java already knows this concept (even polyphormism), it should not be too difficult to realize it - I hope. :cool:
And it's fully backward compatible with already existing code.
 
Last edited:

PaulR

Active Member
Licensed User
Longtime User
A late +1 from me. Now we have classes this would be great to have.
 

MrRey

Member
Licensed User
Longtime User
I wholeheartedly +1 this.

I searched for overloading, and found this.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Given the way B4A is set up, I think it'd be impossible/difficult to add.

Optional parameters would be much better
 

MrRey

Member
Licensed User
Longtime User
I agree that optional parameters would probably be easier. I support either of these ideas.
 

Jost aus Soest

Active Member
Licensed User
Longtime User
Given the way B4A is set up, I think it'd be impossible/difficult to add.
1. Only Erel can finally decide that!
2. As B4A is a kind of Java-precompiler, and Java already knows overloading, I think, it's relatively easy to implement overloading.
(In contrast to e. g. optional parameters, a concept, that is totally unknown in Java.)#
3. As I'm developing professionally in VB and Java, I personally would use both of them, overloading and named optional parameters.

Optional parameters would be much better
As I've already proven in your own thread, optional parameters are only a special case of overloading.
(If you still don't want to accept my facts, read the official arguments from Java insiders like Joshua Bloch: Defining a method with an optional parameter)
So how can "optional parameters" be in any way better? :rolleyes:

BTW:
If you really want to discuss about the facts (with arguments - don't forget Erels' warning about your postings!), please continue in your own thread: http://www.b4x.com/forum/bugs-wishlist/9274-optional-parameters.html
 
Last edited:

moster67

Expert
Licensed User
Longtime User
Come on folks. Let's chill down.

This has already been discussed and all participants have said and argued for their ideas/opinions. At the end it is Erel who will decide what to do.

:sign0089:
 

Jost aus Soest

Active Member
Licensed User
Longtime User

thedesolatesoul

Expert
Licensed User
Longtime User
Why so rude? :confused:
I apologise if I came across as rude, never meant to be. I was just mirroring your behaviour here:http://www.b4x.com/forum/bugs-wishlist/9274-optional-parameters-3.html#post90606
If you felt I am rude, then I felt that too, and I expect you to apologize as I have done here.
Also, I am bored.
Also, I feel you believe something has been proved, just because you said it even though nobody conceded?

I have said nothing about this. I dont mind overloading vs optional params.
As may be you are able to read here

Because discussing without arguments makes really no sense!
I am afraid, as usual, once again you have missed the point!
The question I am asking is why discuss it in that thread and not in this one?
 

Jost aus Soest

Active Member
Licensed User
Longtime User
I was just mirroring your behaviour here
No, you wasn't!

There: I have clarified the facts, while you have ignored all arguments and tried cheating me with a posting loop. :rolleyes:
Here: You are only trolling (trying to kill useful discussions).

Also, I am bored.
Obviously! There is no real reason to kill an important discussion.

I am afraid, as usual, once again you have missed the point!
Maybe it's because you have quoted me incompletly?


The question I am asking is why discuss it in that thread and not in this one?
It makes no sense to discuss the same story in two different threads.
 
Last edited:

thedesolatesoul

Expert
Licensed User
Longtime User
Its hard to discuss something with some one who keeps stating facts over and over and over again.
Also, thanks for telling me I wasnt rude (and eating your words) and not apologizing again!!!

besides, it is true that i am trolling...i always state the truth...infact it is a fact!

Also, I dont think this is an important discussion, maybe you have already forgotten what Erel said in the other thread.
 

Jost aus Soest

Active Member
Licensed User
Longtime User
Is that not what I was asking you in the other topic?
But you have been wrong!

Overloading can solve every problem/task you could solve with optional parameters (but even more), while it's easier to implement in the pre-processor. (Therefor the short notation "overloading > optional parameters".)

So it was a good idea (BTW: from a third poster, "r2d4") to name this alternative for optional parameters.

Summary:
It was very On Topic, that r2d4 and I have suggested overloading!

BTW:
These discussions in the other thread are 5 months old! And now you and NeoTechni are suddenly starting here an offensive...
This tells a lot about your real motivations! :(

But ofcourse you will still not understand.
Sorry that I'm not a native english speaker. :rolleyes:
 

thedesolatesoul

Expert
Licensed User
Longtime User
You should read a thread in context.
As usual you completely miss the point.
Maybe you should spend some time reading what I write rather making closed minded presumptions.

Let me try again:

:confused:
Why is it so hard to stay on topic?
Is that not what I was asking you in the other topic?
But ofcourse you will still not understand.
But you have been wrong!
Henceforth, if I was wrong there in saying that you were off-topic, then I am right here that this thread should be merged with that one since it makes no sense to discuss the same story in two threads (as YOU said).
Hence, you are being hypocritical by starting this thread?
And if you say you are right to start this thread, then I was right in that thread to tell you that you were off-topic.
 

Jost aus Soest

Active Member
Licensed User
Longtime User
You should read a thread in context.
As usual you completely miss the point.
:confused:
You are missing the point! I explain it again:

As "overloading > optional parameters" it makes sense to show overloading to people, who are talking about optional parameters.
It makes absolutely no sense to show optional parameters to overloaders, 'cause optional parameters are not able to solve all overloading-tasks.

BTW: You and NeoTechni here have not shown any arguments - only indicating "I'm against overloading!" - after 5 months you just began a flame war! That's the usual definition of "trolling".
 

Jost aus Soest

Active Member
Licensed User
Longtime User
Thank you, Erel!

Any feature request is valid and will be considered. There is no reason for these endless arguments.
Thank you very much, Erel. :icon_clap:
It was really strange, that after 5 months they began a new flame war...

We should all be polite and treat each other with respect.
100% ACK!
:sign0089:


Basic4android forum is not Stackoverflow (interesting blog post)
Indeed.

Seriously: Everyone should try to help someone learn.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Any feature request is valid and will be considered. There is no reason for these endless arguments.
I have no problem with overloading.
These arguments are endless because people are incapable to understand the points being made and keep singing the same song!


Thank you very much, Erel. :icon_clap:
It was really strange, that after 5 months they began a new flame war...
Better not use big words like flame war etc. Dont flatter yourself :cool:

Seriously: Everyone should try to help someone learn.
If people dont have open minds and do not know how to comprehend what is being said, they cannot learn!
 
Status
Not open for further replies.
Top