#`for` loop, similar to `repeat`

1 messages ยท Page 1 of 1 (latest)

wheat edge
#

syntax:

for 1, 3($index)
  print($index)
; 1
; 2
; 3

for 2($index) ; equivalent to: for 0, 2($index)
  print($index)
; 0
; 1
; 2

for 3, 1($index)
  print($index)
; 3
; 2
; 1

var $min = 0
var $max = 2
for $min, $max($index)
  print($index)
; 0
; 1
; 2

would be suuper handy

ashen glen
#

it is possible to make a "for" loop with "repeat"

#

just gimmie a sec

#

you know the $i?

#

you can use that

#

heres a hand made for loop (no counting down but i might figure that out)

#
    var $max = 15
    var $min = 10
    var $has0 = 0
    repeat $max ($i)
        if $i == 0 and  $has0 == 0
            $i = $min
            $has0 = 1
        print($i)
#

*this makes a thing where it goes from 10 -> 15

#

it also supports min being under 0 (due to the $has0)

#

but yea

#

a for loop would be nice

ashen glen
#

by the way

#

little fun doc thing

#

repeat literally IS a for loop

wheat edge
ashen glen
#

yep

brisk fox
#

Oh @keen dome isn't going to like this suggestion at all ๐Ÿ˜†. Adding the abomination of all loops to his code? ๐Ÿ˜‚

var $i = 0
while ($i > 10)
  ; // do stuff
  $i++```

The new for loop
keen dome
keen dome
#

the usual for ( ; ; ) syntax can always be replaced by something simpler

ashen glen
#

yea i think i can redo a syntax for simplicity

#

for ($i=0;10;1)

brisk fox
brisk fox
#

I knew that was coming.

wheat edge
#

oh yeah damn thats tragic

wheat edge
fervent rover
#

Because of Xenoncode's mindset, which aims to remain a simple language.

More possibilities don't necessarily make the language more difficult, but it becomes indirectly harder due to the growing documentation as the language expands, which gives the impression that it's complex.

All these kinds of small additions make life easier for advanced developers but can hinder learning for beginners, even if in the end they might appreciate having this addition.

In this case, the solution to do the same thing is so simple that Batch doesn't think it's worth supporting an extra syntax that could overwhelm beginners.

wheat edge
#

alright thats fair enough

wheat edge
# fervent rover Because of Xenoncode's mindset, which aims to remain a simple language. More po...

on second thought, i feel that your philosophy is a tad flawed. languages like python are full of features that sure, aren't needed, but really come in handy sometimes. even with all the features, the foundation of it is easy to learn thanks to plenty of documentation and tutorials

essentially, adding features to xenoncode that don't complicate things (like for loops ๐Ÿ˜‰) or are simply optional to use doesn't make the language harder to learn for beginners imo. rather the quality of documentation and tutorials is what dictates whether xenoncode is hard or easy to learn

#

all love though, don't mean to sound like an ass or anything, just want to see more features in xenoncode because the language is a tad limiting in some aspects atm

keen dome
#

Your suggestion is a great one, the problem is there are hundreds of possible good additions like this, each requiring a couple lines in the documentation, accumulating these additions will end up making XenonCode more complicated to learn. Even if the features are optional, they still add things to learn to the documentation for new users.

wheat edge
# keen dome Your suggestion is a great one, the problem is there are hundreds of possible go...

yeah itll undoubtedly make xenoncode a tad more complicated but i dont know man, limiting the language due to the potential of making the language harder to learn doesn't seem too good

imo i think one of your main focuses for xenoncode should be ensuring the foundation of the language (things that are essentially required to learn like functions, variables, callbacks like init, etc) are easy to learn instead of everything as a whole

the language becomes hard or easy to learn depending on your documentation too, so its not really the syntax or buttload of features that makes xenoncode easy/hard to learn but mainly the documentation as said before

keen dome
#

@wheat edge You win this one, I will see what I can do

wheat edge
brisk fox
#

Wait, we're getting for loops?

wheat edge
#

perchance

fervent rover