I’m wondering if Xojo will ever implement shorthand such as:
i += 2
Is this really too big of a fundamental change that it will never be implemented?
Also I’m interested in any techniques anyone may know to shorten Xojo code. I don’t mean on a the level of overall application design. Just simple techniques applied to individual or small groups of code.
[quote=166490:@Nicholas Henson]I’m wondering if Xojo will ever implement shorthand such as:
i += 2
Is this really too big of a fundamental change that it will never be implemented?[/quote]
Discussed endlessly in the past here. It’s very unlikely to happen.
I can’t say that I try too hard to “shorten” my code. I try to keep it clean and clear and readable and sometimes that means you have to be a little more “wordy”. I find it better in the long run, though, instead of trying to interpret a few lines of code that have been reduced down until they aren’t as readable. Just my 2 cents.
Techniques? Try Typinator / Keyboard Maestro / TextExpander. Set your shorthand with one of these and it will replace it for you. I do it quite often, for example I have one that expands dlog( to system.debugLog(|) and puts the cursor where the pole is. If you’re clever enough you could probably get them to do cool things.
[quote=166496:@Dave S]Why would you want to “shorten” code at the sacrifice of readability?
The compiler is smart enough that regardless of which syntax were implemented I’d bet the execuatble would be the exact same size.[/quote]
[quote=166499:@Norman Palardy]Focus on writing clear maintainable code
Long term it saves you far more than typing ++ does[/quote]
I’d argue i++; is pretty easy to read and understand.
Plus i am talking about more than just mathematical syntax. I’m talking about modern coding short hand.
I also write out names in a more readable fashion, but what i’m talking about is more of a syntax modification in general. I love the way the ide is with coding compared to other environments. However, when it comes down to writing code there could be many updates made. (IE. Xojo Language 2.0 like every other language that evolves)
This! is what i’m talking about. That is essentially what the “?:” Operator does in C#. I would love to be able to find more improvements like this. These kinds of implementations allow you to write less code that looks beautiful. It doesn’t look as elegant as the C# implementation, but a much needed improvement.
Here we go again. Is it not amazing that there are regularly people who apparently started with C trying to teach us how to love the so called “more elegant” notation of that family of languages.
A significant number of members of this forum have in the past or still use C for other project. Yet, they have chosen Xojo for very good reasons, and one of them is to be able to use a language made for human beings, close to plain English. Very successful professionals and amateurs alike use Xojo daily to produce excellent programs using the current notation they like.
Why insist on forcing on us an alien syntax coming from another language ? Norman is right. Before asking for decorations on the hammer, learn how not to bang onto your fingers first. Then if decidedly you do not like Xojo because it is not cryptic enough for your taste, go back to C and be happy, without ruining others life.
I chose Basic quite a while ago because I want to remain human. Computers should serve human beings, not the other way around.
Negative, i don’t want to change the syntax. Examples that Gavin Smith posted are what i was looking for with the new implementation of the If and for each.
Firstly i started writing in REALbasic when i was 16 after i discovered that i loved to code webpages so i wanted to try desktop apps. I have never switched languages since and have only dabbled. I love the way C# operates on a fundamental level not a syntax level. I would choose readability over cryptic any day.
These are decorations that could be added and utilized at will or not. It is not something that is forced there any many different ways to write the same statement. I only ask for better options rather than trying to work around missing features.
My only objective is finding shorter solutions to the same problem. For instance like Gavin’s example with the if statement:
if condition then
s = something
s = nothing
s = if (condition,something,nothing)
^ This right here is beautiful and the kinds of implementations i’m talking about
need is “a way to increment an integer” which i = i + 1 does already
I’m not saying it wont happen - we’ve discussed some - and there is a feedback feature request for them - its just a lot lower priority than say 64 bit, LLVM and the other items on our list (and yes its a fair amount of work to implement since you have to change the grammar, the parsers, compiler etc)