Shop OBEX P1 Docs P2 Docs Learn Events
to those reely, reely familiar with PBASIC — Parallax Forums

to those reely, reely familiar with PBASIC

davejamesdavejames Posts: 4,047
edited 2014-11-30 18:32 in BASIC Stamp
Is there any advantage (any at all) in combining PBASIC statements on the same line versus separating them on individual lines?
<statement1> : <statement2> : <statement3>

...versus...
<statement1>
<statement2>
<statement3>

Thanks much.

Comments

  • SapphireSapphire Posts: 496
    edited 2014-11-30 16:22
    Only for readability. Tokenization is the same either way.
  • Hal AlbachHal Albach Posts: 747
    edited 2014-11-30 16:30
    I tried this out on a simple demo program that had three statements in a for...next loop. Looking at the EEPROM map nothing changed, all the tokens remained the same and the map ended at the same location. I kind of figured that was going to happen but it's always good to see your hunches pan out. About the only benefit to packing multiple statements on one line would be some paper saved if you are the type that likes to print everything out and don't mind a certain amount of confusion. It also makes commenting your source very difficult since only the last statement in a line can have a comment.
    I would not want to debug someone else's code if they filled every line with multiple statements. Lots of white space makes for easier reading and debugging.
  • davejamesdavejames Posts: 4,047
    edited 2014-11-30 17:28
    Sapphire & Hal,

    Thanks guys, I kinda figured as much. But always hoping for anything that would bring a bit more performance.

    :smile:
  • JonnyMacJonnyMac Posts: 9,157
    edited 2014-11-30 18:32
    There's a popular line from Star Wars that's appropriate: "It's a trap!!!"

    The tokens will be the same, hence you should always go for readability -- make your listings easy on humans.
Sign In or Register to comment.