there is a language feature I would really like to have in xojo. multiple return values.
I know you can pass parameters byref and have the feature, but I find this confusing
mainly because you dont know if you have a lot of parameters which one is returned or not.
you have to deal with the array after passing to the method, and itâs not âeasyâ as to have the values in each variable
most of the times I would only have 2 may be 3 return values, never a big size (where I would use arrays)
Use a dictionary, JSONItem or a custom class (this allows auto complete in the IDE too)⊠I think pretty much every language requires you to either use ByRef to âreturnâ multiple values or to return an arrayâŠ
old âoriginalâ oop programming languages used to have multiple return values syntax without byref
Lisp, prograph, dylan, among others (ada also I think ?)
[quote]Functions with Multiple Return Values
You can use a tuple type as the return type for a function to return multiple values as part of one compound return value.
The example below defines a function called minMax(_:), which finds the smallest and largest numbers in an array of Int values:
[/quote]
[code] func minMax(array: [Int]) -> (min: Int, max: Int) {
var currentMin = array[0]
var currentMax = array[0]
for value in array[1âŠ<array.count] {
if value < currentMin {
currentMin = value
} else if value > currentMax {
currentMax = value
}
}
return (currentMin, currentMax)
}
To LISP OOP features were added some 20 years after the language was invented.
Prograph is not a 3rd generation programming language AFAIK.
Dylan has its roots in LISP and was one of the attempts to mingle OOP into LISP while modernizing LISP at the same time. But Dylan is not really alive (which is sad  I love this programming language!).
Simula as first OOP language did not have multiple return values. Smalltalk, C / C++, C# / VB .NET, Objective C, ALGOL/Pascal-based OOP languages (which includes Ada) all do not support multiple return values. Java neither as far as I know.
All languages which have procedural roots do not support it due to how compilers work. Over the time as compiler development has evolved, this has changed of course, and for example Swift  which has been heavily influenced by non-procedural / non-OOP languages  supports it (which means the LLVM-team must have introduced that feature at some point).
Personaly I have never missed this feature. But you could use Pair for two return values. Or you could create your own class.
I dont want to use a pair or a class or an array to do that.
because you have to assign the values to the array/pair/class before
and then get the values back into the variables after the method
thatâs at least 2 lines per variable
with the ânewâ syntax itâs all in one line.
The main reason IMHO against multiple return values is: if the data returned is related to each other it should be an object, an array, or a dictionary. If it is not related to each other, it should not be returned by the same function, but by two or more functions returning each value by itself (Data Clump)
By the way, it is the same with out parameters: one is acceptable, two or more are not. A valid case in C is for example outCount as an âout parameterâ while the function returns the pointer to the array.
We have stuff that will work with a little effort, no one is questioning that. But I think he phrased the question as a possible feature request. Must be some reason why Swift thought it was important enough to add, there are ways to workaround it in Swift too. Sometimes I wish I could get more than one return value back without returning a class or an array, would make things easier in some respects, but I am sure there are a lot more pressing feature requests.
Altering the language in this fashion is not âtrivialâ
Iâd return a class instance even if all the class does is wrap up several values and has no methods
Somehow all those return values are related
Prograph is entirely different from every language I have ever used
Itâs a data flow / object flow based language that uses a visual IDE
Still exists as Marten
I think using a class, or other form of grouping the return values, and returning just a single value is probably better for forward compatibility (I know most people just think about backwards compatibility)⊠Plus, by using a class (at least in Xojo), it gives you auto-complete in the IDE for the different properties and methodsâŠ
[quote=199779:@Norman Palardy]Prograph is entirely different from every language I have ever used
Itâs a data flow / object flow based language that uses a visual IDE
Still exists as Marten[/quote]
I loved Prograph and wrote my first major shareware app in it. To bad I was in a minority.