How do we ensure that method type inference terminates?

I missed the party. I was all set to be on that massive wave of announcements about TypeScript, and then a family emergency kept me away from computers from Thursday of last week until just now, and I did not get my article in the queue. Suffice to say that I am SUPER EXCITED about…


Why Doesn’t C# Implement "Top Level" Methods?

C# requires that every method be in some class, even if it is a static method in a static class in the global namespace. Other languages allow “top level” functions. A recent stackoverflow post asks why that is. I am asked “why doesn’t C# implement feature X?” all the time. The answer is always the…


Using undefined variables in JScript

I got a question the other day pointing out that in JScript, it is legal to assign a value to an undeclared variable, and the variable kind of gets implicitly declared for you, but it is not legal to read the value of an undeclared variable. The writer wanted to know if y = 1;…

5

Checking For Script Syntax Errors, This Time With Code

A number of people asked me to clarify yesterday’s entry. Rather than try to talk you through it, I think the code is straightforward enough to speak for itself. Here’s a little skeleton that I just whipped up. #include <stdio.h>#include <activscp.h>#include <new> const GUID CLSID_VBScript = {0xb54f3741, 0x5b07, 0x11cf, {0xa4, 0xb0, 0x00, 0xaa, 0x00, 0x4a, 0x55, 0xe8}};const…


Checking For Script Syntax Errors

A reader asked me recently whether there was a way to check a chunk of JScript or VBScript for syntax errors without actually running the code. I’m sure that there are many third-party tools which you could find that do this. If you have your own script host, you can do it yourself quite easily….


Local variables considered not very harmful

Like I said, that code from last time was just test code, not real production code. Though clearly it works, I’d never write code like that in a million years. I’m not thrilled with the way it uses the answer variable of the outer scope as an accumulator, and it is profoundly weird that the “do…


Guru meditations on scope chains of closures

I just had a really interesting meeting with some of the scripting community MVPs.  I may write up some notes on that meeting here next week, so watch this space. In other news, someone asked me last night (and I quote) Oh ECMA guru, can you provide a succinct explanation of why the following code works, but…


C# 3.0 is still statically typed, honest!

Since LINQ was announced I’ve seen a lot of really positive feedback and a lot of questions and concerns. Keep ‘em coming! We need this feedback so that we can both correct misconceptions early and get the design right now. One of the misconceptions that I’ve seen a lot over the last few days in…


Implementing Event Handling, Part Two

It’s been an insanely busy month for me, between having multiple out-of-town guests, throwing a party for the people who couldn’t make it to the wedding, and oh yeah, getting up to speed on the C# compiler and trying to understand the implications that LINQ features are going to have on the current implementation.  Not…


Recursion, Part Six: Making CPS Work

JScript doesn’t support CPS natively but we can write another dispatch engine that makes it work. There’s only ever one active continuation, so lets have a new rule:  JScript CPS functions are allowed to return, but the last thing that they do must be to tell our dispatch engine what the continuation was. To keep things…