Using Arrays

Xojo arrays are easily used as stacks and queues. There is already a pop method which removes the last item and returns it.

Would it make sense/be useful to have push, enqueue, and dequeue methods? This would make it more obvious to a reader of the code what the intent was.

Push and enqueue do the same as addRow.

dequeue would remove the zero item and return it.

I don’t like the redundancy of push and enqueue, but I do agree that a first-in-first-out function (as opposed to the last-in-first-out nature of Pop) would be welcome.

But I’d call it PopTop. :slight_smile:

1 Like


I don’t have a problem with the redundancy. I think having the added terms would make code more readable, which I believe is somewhat important.

1 Like

The counterpoint is, it clutters the language.

That said, if Xojo decided to do that, I’d have no problem with it, but I can’t think of another place where they’ve done that.

< cough >Generics < /cough >
something like

var intQueue as Queue<integer>
var stringQueue as Queue<string>
var intStack as Stack<integer>
var stringStack as Stack<string>

which is basically what you’re trying to fake by jamming all this into a single notion of “array” which isnt a data type in and of itself

Kem’s right in that they’ve never done this before (make an “alias” of a keyword). However, there are a number of places where this might be useful especially for beginners. For example, “addressof.” I believe this is the only place where Xojo talks about addresses. It might be easier for a novice to see “dothis:” or “using:”.

And, why have a special pop keyword and not push?

Then just add the methods yourself in a global module using the Extends keyword. This lets you add your own methods with whatever logic / naming you want – even if all the method does is an addRow or pop or whatever.

If you use a generic name like “push” or whatever you have the potential for a naming conflict if Xojo ever introduces that same name in the future. Some people like to add a prefix or suffix to help minimize name collisions.

1 Like


I thought of that, but arrays can hold anything. I’m not sure (never tried) to do an Extends where it would work with anything. I wouldn’t want to create methods for all sorts of datatypes.


You would need to create a separate extends for each data type.