If you were going to add to the Xojo language

Resumable Subs

1 Like
// Tuples

Function f (x As Integer, s As String) As (Integer, String, String)
  Return (x-10 , "Result", s+x.ToString) // Returns 3 values at once, a tuple
End

// More complete var declarations and Nullables continuously
Var a As Integer = 3, b As Boolean = False, c As Integer,
      d = e = f As Double = 1.0, // d,e,f are doubles set to 1.0
      g,h,i As Integer, j As ?Integer, // g,h, and i are integers, and j is a nullable integer
      s As ?String // Nullable string

// Types
Type  (a, b, c As Integer, s As String) As MyTuple // Define MyTuple as a new type

Var mt As MyTuple = (1, 2, 3, "values of the tuple set")

Var mt2 As (k, l As String, i As Integer) // Define a new tuple directly
Var m33 As (a,b,c,d,e As ?Boolean) = (true, true, false, nil, true) // Define a new tuple with 5 nullable booleans and set them 

MessageBox(mt.s) // show "values of the tuple set"

// Multi set values returned, discard some

(c, _, s) = f(100, "done ") // call f(), set c = 90, discard what should be "Result", and set s = "done 100"

if(j = Nil) Then Messagebox("j is integer, but also can be nil as it is nullable") // j is nil as it is not initialized, a 0 is not a nil, it is a value

1 Like

return more than one type would be very good, I use an array at the moment, but its a little cumbersome.

plus the ability (as already mentioned) to not need CALL if the return value is not required.

and something that drives me mad, if there is only one event, why do you need to go through all that selecting to add it.

I am a 19r1.1 API1 only user so its possible some might be fixed now.

That seems just a kind of Async/Await

Futures and Async/Await are a more complete set: https://dart.dev/codelabs/async-await

Another nice feature, which is impacting me as I speak, would be a way to mark events as required (i.e. you get an error if you don’t implement such an event). This might be a language feature, or it might be an IDE feature.

You know that Xojo put async and await on the list of reserved words long ago?

@beatrixwillius, Did you mean to downvote this suggestion about returning multiple values from a method? If so, I’m curious why you think this isn’t a good thing.

I guess they figured that someone at some point would figure out how to make Xojo compile multi-threaded apps…

Nope, but it is a good reservation.

Async/Await is a smart cooperative way of squeezing more processing power from just one thread.

Interesting. It came out after I stopped doing .NET stuff, but I would have only used it as an easy way to multi-thread. I had to use the old-fashioned way in my day (Tokens)

This would be a couple keywords
ABSTRACT - force subclasses to implement it
FINAL - means subclasses CANNOT override this implementation

And WITH END WITH and several others
They’ve been on that list for a VERY long time

For me personally, I’ve seen some good suggestions already, one I’d love is to duplicate the Obj-C Macros capability (not really a language improvement).

So you could write C = foo( A, B ) and on compile time, this would inline the foo macro, avoiding the overhead of methods/functions.

Lots of great ideas !

Well ABSTRACT wouldn’t really cut it since that just forces a subclass to implement a method, not to force an instance of a class to implement an event. But I guess it could be used for both.

Yeah I guess events are already ABSTRACT so thats not an issue

Some thing like REQUIRED as an attribute etc might suffice to say “instances MUST implement this event”
That is awkward as heck to do in Xojo and the bets you can do is a runtime error if the class check to see that the event is implemented using IsEventImplemented

At least this way you could check its implemented before raising it and raise a runtime exception if its not

A compile time warning / error would be much nicer

IsEventImplemented would be the answer, but it doesn’t exist in 2019r1.1, which I am currently “forced” to use.

@Walter: I’ve been traumatised by Python. And returning multiple values from a function was the last straw.

I can return arrays, dictionaries, pairs and objects from a function.

For the other additions: there are many wishes. But I would like to see why you need the language addition and an example on the benefit of the new feature.

The typical “I want xxx” doesn’t really cut it.

For instance take closures: I read about them a couple of times. I still don’t understand what I would use closures for.

Just say no to “x+=y”. This results in messy code.

What are embedded functions useful for?

“with” I jused in VBA all the time because of the MS object model. I had to use class1.class2.class3.class4.class5 for creating Excel charts for instance. Using “with” was practical. For Xojo I have never used such an abomination.

My brain is simple. I don’t want to use complicated constructs.

2 Likes

I understand why you dislike certain things that have been suggested
But lets please not turn this into a “I hate feature X from language Y”
That wasnt the point
This is just a “I wish” kind of thread at this point
Its just brainstorming so hold up on judgments at this point

2 Likes