No, I need to be able to replicate the exact same functionalty that Xojo provides
the problem is I can’t find anything that allows me to put a value to a “function” using the “=” sign. The closest is a computed variable, but you cannot pass other parameters
I can’t envision a methodolgoy that would allow that.
Xojo seems to allow two methods for passing values to a function, parameter and/or assignment, I’m trying to figure a way to “fake” the assignment method, and still allow overloads to be viable.
Current train of thought is something along this line (not that I really like this idea)
BASIC
FUNCTION foo(bar as Integer, assigns S as string)
stuff....
END FUNCTION
FUNCTION foo(bar as Integer) AS String // overload
return "xyz"
END FUNCTION
SUB TEST()
foo(32)="abc"
END SUB
SWIFT
func foo(bar : Int) {
var s : String
var assign : String { set ( s=NewValue} } get { return "" } }
}
func foo(bar: int) -> String {
return "xyz"
}
func test() {
foo(32).assign="xyz"
}
Overriding the = operator for the type would seemingly let you do this
I dont know the specifics as I’m not nearly as Swift literate as you BUT in C++ you can do this as well and make several = functions
The pages I linked to have examples of some (written as extensions)
extension Vector2D {
static func += (left: inout Vector2D, right: Vector2D) {
left = left + right
}
}
and you’d use this just like you would any += operator in Swift
= can also be overridden like this (as can most operators)
I’m not sure there is any language that permits something that is syntactically equivalent
Most of the time when you see the = operator overloaded its basically performs what “operator_convert” would do when you assign from one type to another