syntactic sweeteners, part ][

(A small update to yesterdays thoughts on syntactic sugar)

First here's a chunk of Linq, that i think might be fairly valid (though i haven't (a) compiled it or (b) ever actually compiled any linq code... so whadda i know??)


List people = DB.GetAllPeople();
var oldPeople =
   from p in People
   where p.Age > 29
   select new {p.FirstName,

Console.WriteLine("Some old People:");
foreach (var x in oldPeople) {
   Console.WriteLine(x.FirstName + " is old.");

Now here's my idea for how the syntax could get even simpler, by using more "inferences"....

List people = DB.GetAllPeople();
var oldPeople =
  from People
  where value.Age > 29
  select new {value.FirstName,

Console.WriteLine("Some old People:");
forevery (oldPeople) {
   Console.WriteLine(value.FirstName + " is old.");

Okay -- so this is a bit like yesterday's "in (people visit Person p)" example -- except here we simply say "forevery (people)" and then access the keyword "value" to refer to the member within the collection.

Also in the linq query instead of "from p in People" we just say ""from People" and then rather than use the variable 'p' we use the keyword 'value', (much like in a property setter).

I'm really gonna stop thinkin about silly syntax soon. This is perhaps not as bad as the time a few months ago when i started trying to invent ancestors for xml.


My book "Choose Your First Product" is available now.

It gives you 4 easy steps to find and validate a humble product idea.

Learn more.

(By the way, I read every comment and often respond.)

Your comment, please?

Your Name
Your Url (optional)
Note: I may edit, reuse or delete your comment. Don't be mean.