Hello,
str() has always existed—why should one use .tostring for everything now?
var a as string
a = str(1+1*2+1.2,“00.00”)
messagebox a
rem = 04.20
Apples and oranges. Your IF example does not use an extension method. While one might expect the extension method in the original example to work, Xojo’s compiler simply doesn’t work that way. I’m sure it could be implemented, but it is very unlikely to get any priority.
Because str(variable) is API1 and variable.toString is API2.
If you double-check my comment, I was responding to a related assertion by another poster about how Xojo treats expressions encapsulated in parens.
In OOP (like Xojo) or MP POP (Protocol Oriented like Swift) or MP TBP (multi-paradigm, trait based, like Rust) there’s a common feature called chaining that allows to write short, clear and readable direct expression sequences. And that’s a more modern way of writing code.
So an old way like
x = AddSuffix(AddPrefix(Str(v1 + v2, “#0.00”)))
Chaining is more clear, direct and less error prone (like bad parenthesis matching) as
x = (v1+v2).ToString(“#0.00”).AddPrefix().AddSuffix()
As @Lawrence_Johnson pointed out, Str() is not deprecated, therefore it is in API2, probably for the reasons we’re discussing.
I’m not so sure about that. But then again I may be prejudiced as the language I have used more than any other (and even written a textbook on) was LISP.
Nope, LISP is another kind of animal that suffers the same problem of Xojo and matching parenthesis. I hated it. I used a bit of LISP and PROLOG in the past. Pain.
Importantly (at least for left-to-right readers) the order of operations is the same as reading direction. The old nested syntax has to be decoded from the inside out and can quickly get disorienting.
That isn’t true for Xojo and even as far back as VB.
Like in math, and chaining as in math.
The chain return an object, and you can fire a new method of such object.
This isn’t referring to math operations, it’s referring to methods and the order in which they are called when you chain them.
What does that have to do with API1 vs API2? It’s 100% only not deprecated because Xojo isn’t known for consistency.
But the precedence of . (Dot), which is an operator, and + (plus), does come into it. In the example given
1+1.ToString
The dot has the higher priority, so it would read as
1 + ( 1.ToString )
And not the other way around. That is not left to right. Presidence is not just about maths.
But what makes you think Str isn’t part of API2 anymore? I couldn’t find anything in the documentation or the IDE itself suggesting one should replace Str by toString with API2.
Str() still a current option. The “move away list” is here:


