Menu

Shorthand ideas

brentoboy
2005-03-19
2013-03-08
  • brentoboy

    brentoboy - 2005-03-19

    Java/c are so much better than BASIC when it comes to shorthand, mostly because BASIC has no support for shorthand.  Event Visual Fred doesnt support all the shorthand java and c# do - like   the ++ shorthand operator.

    Obviously we need all the standard shorthand operations
    x += 5
    x++
    etc.

    Basically any binary operator should be able to be shortened if it follows the same syntax as ...
    x =x + 5 then it can shorten to x += 5

    I dont think anyone disagrees on that point.

    However, as much as I like x++ I think ++x creates room for newbies to make mistakes and become confused.

    I hate to say that, because I have made plenty of good use of the ++x syntax, it shortens things a great deal, but this reads a lot easier.
    x++
    DoSomething(x)
    is more readable than
    DoSomething(++x)

    Brevity is only better if it doesnt add confusion.

    ---
    Anyway, we need shorthand that allows for this...

    1 < x < 10
    Which is shorthand for
    (1 < x) And (x < 10)

    My high school algebra class used this syntax, why didnt software development do pick up on it? it is so common to want to do something like that, so lets add it.

    In fact lets allow for any length of an inequality chain, and split it up by anding it together... like so

    1 < x < 10 = n > 12 expands to this...
    (1 < x) and (x < 10) and (10 = n) and (n > 12)

    There is another place we need some shorthand
    It is so common to say
    Function Max(Int x, Int y) Returns Int
    That it could be shortened to
    Function Max(Int x, y) Returns Int

    We can declare 2 or more variables on the same line by separating them with a comma, and nobody complains, so why not inside of a function declaration.

    any other shorthand suggestions out there

     
    • brentoboy

      brentoboy - 2005-04-03

      I was mistaken,

      it looks like Python allows for this sort of "shorthand"

      1 < x < 10

       

Log in to post a comment.

MongoDB Logo MongoDB