Continue Line

This topic contains 26 replies, has 12 voices, and was last updated by  abakobo 1 year, 5 months ago.

Viewing 12 posts - 16 through 27 (of 27 total)
  • Author
    Posts
  • #7193

    nobuyuki
    Participant

    I don’t like line continuation characters at all.  If there’d be only one change to make, I’d request that “+” qualify as a continuation character, or make all operators qualify.  Don’t know how messy that would be, but I’d presume that using “..” will be unfun for parsers and/or preclude using it in the monkey1 way for slicing (is that even a thing anymore?)

    #11270

    therevills
    Participant

    Is there a format to split an “IF” statement over multiple lines?

    #11271

    Mark Sibly
    Keymaster

    Not currently, I haven’t felt the need so far for anything beyond the current scheme of allowing line splitting after ‘(‘, ‘,’ and ‘[‘. That’s just the way I like to code I guess – if a line get so long it’s wider than a page, I like to break it into bits. Ditto with functions longer than a page(ish).

    But that’s just me. The ‘..’ token is currently unused and I’d be OK with adding that for line ‘continuation as it’s clean and simple and makes it obvious that you are in fact splitting a line.

    #11273

    therevills
    Participant

    Good! Thought I was missing something and I was trying everything to get it to work 🙂

    In MonkeyX1 I had:

    [/crayon]

    But in Monkey2 its currently:
    If _level.GetCollisionTile(tempX - w2 , position.y + h2 - 1 ) = 0 And _level.GetCollisionTile(tempX - w2 , position.y - h2) = 0 And _level.GetCollisionTile(tempX - w2 , position.y) = 0

    (hmmm that is meant to be one long line…)

    So its a bit long to read nicely…

    #11276

    Mark Sibly
    Keymaster

    In the meantime, you could break long ‘And’ If statements into multiple block Ifs, eg:

    This is what I tend to do – I like having just one statement per line (as you might have guessed).

    #11278

    therevills
    Participant

    Yeah, but I needed an ElseIf for all the conditions 🙂

    [/crayon]

    In one place I did split it up like so:

    [/crayon]
    #11279

    AdamStrange
    Participant

    add stuff, but don’t break stuff.

    #11280

    Mark Sibly
    Keymaster

    add stuff, but don’t break stuff.

    Definitely! EOL handling is strangely tricky, but think I have it covered this time around.

    #11284

    therevills
    Participant

    My preference would be to use “And” / “Or” as the line continuation instead of .. if possible 🙂

    #11293

    EdzUp
    Participant

    I vote for the ‘..’ to split lines, strings should just be added to itself ‘MyString += “My text’ sort of thing.

    #11294

    therevills
    Participant

    “..” isn’t intuitive though and seems like going backwards to me as Monkey 1 had And / Or.

    #11303

    abakobo
    Participant

    “..” and “And” and “Or” !?
    All of them would be usefull..

Viewing 12 posts - 16 through 27 (of 27 total)

You must be logged in to reply to this topic.