The book of inspiration

March 2, 2007

initial linq to objects support for javascript

Filed under: jsc — zproxy @ 9:57 am

After some updates to the jsc compiler one can now write something like this:

 

34 var a = new [] { “_a”, “_x”, “cc” };

35

36

37

38 foreach (var v in

39 from i in a

40 where i.StartsWith(“_”)

41 select “select: “ + i)

42 {

43 Control.appendChild(new IHTMLDiv(v));

44 }

And the browser will show:

select: _a

select: _x

The good news is that you can now write your own custom delegates and you can use query keywords select and where . The bad news is, that these iterators were coded manually, which means the compiler must get smarter in that area to be able to automate it.

You cannot compile the example at the moment, but you can look at the c# source code.

The next thing would be to make the same thing available under php and then release the new jsc compiler on the web page so you could try it out yourself.

Update:

I made the example interactive. You can see it working over here.

Good News:

“We introduce nested iterators, their proof rules and fast implementation, which are
expected to appear in one the next versions of C#.”

Advertisements

Blog at WordPress.com.