Oi! Make your own thread for other languagesDoes such a table exist in Java, for example? With equivalences to C++, C#, Python?
I have no idea what do you mean by Protocol. From what I can guess, Java has concept of Interface which is similar or different implementation of Class. In some programming languages like .NET or PHP, there is Namespace. I think it is similar concept. B4X supports Class which we can reuse the code module and initialize an object from the Class. B4X also has Type, which is similar to struct.
if someInstance isA CanDrawItself then
What I am missing is a high-level introduction for people coming from other languages.
An open question about a container concept such as protocol and interface cannot be answered. A network administrator then thinks of things like TCP/IP, UDP and so on. With an interface he things like a component such as Bluetooth, Ethernet, USB, while a security officer thinks of a lot else with the word protocol for the same container concept.And what is the B4 equivalent to a Protocol / Interface?
#Event: NameEvent (parameters Ad Type, ...)
'Class Person module
Sub Class_Globals
Private FirstName, LastName As String
Private BirthDate As Long
End Sub
Sub Initialize (aFirstName As String, aLastName As String, aBirthDate As Long)
FirstName = aFirstName
LastName = aLastName
BirthDate = aBirthDate
End Sub
Public Sub GetName As String
Return FirstName & " " & LastName
End Sub
Public Sub GetCurrentAge As Int
Return GetAgeAt(DateTime.Now)
End Sub
Public Sub GetAgeAt(Date As Long) As Int
Dim diff As Long
diff = Date - BirthDate
Return Floor(diff / DateTime.TicksPerDay / 365)
End Sub
'Main module
...
Dim p As Person
p.Initialize("John", "Doe", DateTime.DateParse("05/12/1970"))
Log(p.GetCurrentAge)
Python us similar Swift for protocolDoes such a table exist in Java, for example? With equivalences to C++, C#, Python?
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def myfunc(self):
print("Hello my name is " + self.name
protocol Polygon {
func getArea(length: Int, breadth: Int)
}
// conform the Polygon protocol
class Rectangle: Polygon {
// implementation of method
func getArea(length: Int, breadth: Int) {
print("Area of the rectangle:", length * breadth)
}
}
// create an object
var r1 = Rectangle()
r1.getArea(length:5, breadth: 6)
What I meant is that the OP would like a table with equivalence between the keywords of 3 languages: Swift - Xojo - B4X, but he will never find documentation of a language in which such a table exists, he will not find documentation on Java in which there is a table with Java keywords and analogous C++ keywords and C# keywords etc.Python is similar Swift for protocol
No, they were two@LucaMs I think that you misunderstood what OP's question is.
Even something like a simple table showing what is equivalent or can be used instead of would be helpful, eg
Swift - Xojo - B4
Var - Dim / Var - Dim
Let - Const - Const
That is neither an answer nor advice - what was the point?Does such a table exist in Java, for example? With equivalences to C++, C#, Python?
I still fail to see your point. Something doesn't exist so it should never be made? It doesn't exist so it would not be useful to make it?What I meant is that the OP would like a table with equivalence between the keywords of 3 languages: Swift - Xojo - B4X, but he will never find documentation of a language in which such a table exists, he will not find documentation on Java in which there is a table with Java keywords and analogous C++ keywords and C# keywords etc.
So...!
Seems an introduction is in order.So what do you want to realize with B4J?
Most modern programming languages, in the hopes of enhanced maintainability and reusability of code, offer some constructs that help the developer keep the definition of behavior and its implementation separate. Swift takes the idea of interfaces a step further with protocols. With protocols and protocol extensions, Swift allows developers to enforce elaborate conformity rules without compromising the expressiveness of the language. In this article, Toptal Software Engineer Alexander Gaidukov explores Swift protocols and how protocol-oriented programming can improve the maintainability and reusability of your code.
protocol or interface is a model that defines the set of properties and methods of an object / class
if someInstance isA CanDrawItself then
Unlike the obsolete languages you mentioned
Oi! Make your own thread for other languages
Yet it is quite basic.I still fail to see your point. Something doesn't exist so it should never be made? It doesn't exist so it would not be useful to make it?
I express my opinion whether you share it or not.Please don't troll. It is unbecoming.
It happens that you are not registered, make a donation or purchase to become oneOthers keep telling me they were NEVER moderated, so what is going on???
It sounds like you could be talking about what is called traits in php, could that be right? In that case the answer would be no, there's nothing like that in B4X.The important point about interfaces / protocols is that they allow you to combine very different objects into one type based on similar behaviour or capabilities - you are not restricted to a hierarchical class structure.
Standard procedure for all unlicensed users. Most users got here to the forum after buying a B4X product, making them licensed from the start, so most users have never been moderated and thus haven't seen that message. It's just a way to keep spam out and keep the forum a nice place.And still "This message is awaiting moderator approval, and is invisible to normal visitors." for nearly all my messages?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?