Jaa


All programming languages evolve towards Lisp

2007_01_28 120

In an internal DL people were debating what all should be included in the next version of C#. One of the things I suggested turned into an interesting thread.

Abhinaba: Add if as expression (like in Ruby) so that I can do the following

 var ageGroup = if age < 2
                   "Infant"
               else if age < 19
                   "Teen";

SomeOne: Can't we do

 var ageGroup = ((age < 2) ? "Infant" : ((age < 19) ? "Teen" : String.Empty));

Abhinaba: We can but put 4 more cases and it’ll start looking like Lisp :) with all the parenthesis.

SomeTwo: All programming languages evolve towards Lisp.

Yeah, right!!!

 

Cross posted at my personal blog.

Comments

  • Anonymous
    November 20, 2007
    The two code samples are semantically different. In the hypothetical if version, what is the value of ageGroup if age is, for example, 20? I would assume null. However, a variable of type var can not be set to null... You'd either have to either explicitly type it to be a String, and / or include an else block. In the ternary operator version, it becomes an empty string, different from the above version. Let me tell you what I want (and have been begging for since before Whidbey was released):
  1. Variance support. At least with interfaces to begin with. (A few good blogs about it recently.)
  2. Operator overloading in generic types. Need a way to declare that a type implements a specific operator (which happens to be static!).
  3. There is no way to know what types are addable, subtractable etc. Create an IAdd, ISubtract, IMultiply etc and apply them to the base types as appropriate. Implement nothing but these and I will be extremely happy.
  • Anonymous
    November 21, 2007
    The comment has been removed

  • Anonymous
    November 21, 2007
    It's evolving towards F#; in other words, towards OCaml and ML (some will argue that the latter is Lispish in nature, though).

  • Anonymous
    November 21, 2007
    (define age-group  (cond   ((< age 2) "Infant")   ((< age 19) "Teen")))

  • Anonymous
    March 30, 2008
    Hmm, I wonder what LISP would look like with significant whitespace instead of parentheses...