Operator_compare

Ever wanted to define a class, maybe a vector class, and make it possible to write code like

dim v1 as new Vector(1,1)
dim v2 as new Vector(2,2)

if v1 v2 then
  // do something when v1 v2
elseif v1 < v2 then
  // do something when v1 < v2
else
  // do something when v1 = v2
end if

Perhaps you have some other kind of class you’d like to define that has some kind of custom mechanism to compare itself to other instances – or even other data types.… Read the rest

Method signatures

I know I’ve probably used this term a bunch in other blog posts but I don’t think I’ve ever explained what a method signature is.

In Xojo a “method signature” is the unique way Xojo identifies each method so it can know which method you are calling in your code.

So what does that include ?… Read the rest

2019r3

I’ll admit that I really haven’t seriously touched R3 since most of its focus was on iOS and dark mode which isn’t something that matters to me.

The times I did start it I found it to still be slow like R2.1 and otherwise not many significant differences in the things I was trying.

Autocomplete is still glaringly bright in dark mode on macOS.… Read the rest

Overloading

No not your plate (despite it being right around American Thanksgiving)

Sometimes when you write your code its convenient to have several versions of “the same” method.

For instance, in Xojo you might look at the AddRow method on the Listbox class )in 2019r1.1) and see that it has several forms

ListBox.AddRow(ParamArray Item as String) 
ListBox.AddRow(items()
Read the rest

Operator_Convert

Operator_Convert is a very handy method to implement on a lot of classes. It not only lets you create a mechanism to make your classes convert themselves into other types but it also lets you create new instances FROM other data types.

So let’s start with the simple forms of operator_convert – the “convert TO” forms.… Read the rest

Using interfaces (again)

A recent comment on my post about overriding prompted me to write this second post about interfaces and why you might use them. Its clear to me that I havent done a very good job of explaining why you should or would use them.

In some languages you can create classes that inherit from one other and one other only.… Read the rest

Sorry about this week folks

I’m feeling a little under the weather and just dont feel up to writing more posts

Hopefully this will pass soon enough

FWIW IF there is a topic you’d like me to cover drop me a comment or email

Overriding

Sometimes when you create a subclass you want to your subclass to do something different than the class it inherits from. But you want to retain the API or reuse the method name because its perfectly suited.

When you do this and add a method that has the EXACT SAME signature as the one in the superclass you are overriding the method.… Read the rest

Faking named parameters

Xojo doesnt support named parameters. And I dont expect they are likely to add it any time soon. But, you can kind of fake it for yourself with a bit of work.

Xojo supports both variadic parameter lists, ones that take an unbounded list of parameter, and a declarative syntax for creating pairs as literals.

You can combine this into faking named parameters.… Read the rest