Why no ++ and –, redux

Since we’re on the subject of language differences today, it’s worth noting that Eric Lippert wrote his own entry on why he thinks VB shouldn’t have ++ and —. I’m not sure if he saw my original thoughts on the subject, but it’s interesting to see the similiarities and differences in reasoning. Eric also privately asked me about a different reason for not requiring Partial on partial types, but I’m going to cover that later this week – I’ve blogged enough for today.

3 thoughts on “Why no ++ and –, redux

  1. Mike Schinkel

    From your prior post:

    >> If we introduced ++ and — as assignment expressions, then it would be weird not to allow general assignment expressions. For example, in C#, you can say "if ((x = foo()) == 10) {}" and have the assignment done as part of evaluating the if expression. The problem, as you might have already guessed, is that we already use the = operator in expressions for testing value equality. Thus, there would be no easy way to introduce general assignment expressions into the language, which would make it strange that we had — and ++.

    I used to program in a language called Clipper, and when the introduced inline assignment they used ":="

    BTW, that’s one of the several things I *really* miss about Clipper when programming in VB. Another is "Codeblocks", which were like anonymous functions (I’m using Clipper syntax to the best of my memory):

    // This multiples the two codeblock parameters

    b= {|p1, p2| p1 * p2 }

    ? b.Eval(10,20) // Prints 200

    Of course code blocks were only useful when they were passed to subroutines. That of course created lots of interesting scoping issues. Here is another codeblock example:

    // This multiples the two codeblock parameters

    srt= {|p1, p2| p1 > p2 }

    arr= { 5, 12, 3, 9 }

    ArraySort( arr, srt )

    For Each e In arr

    ? e // Printed, in order, 3, 5, 9, and 12

    Next

    Reply
  2. paulvick

    Mike, code blocks are a lot like C#’s anonymous methods. It’s something we’re definitely looking at for the future (i.e. not VB 2005).

    Reply
  3. Chris

    Hey, how’s it going Mike? I still miss Clipper–especially v5.0. Very powerful environment. I especially miss the product’s include file capability

    Reply

Leave a Reply