The JScript Type System, Part Six: Even more on arrays in JScript .NET

You might have noticed something odd about that last example using SetValue. If you actually look up the method signature of SetValue in the CLR documentation it notes that the function signature is:   public function SetValue(value : Object, indices : int[]) : void   The odd thing is the annotation on indices. It is…

5

The JScript Type System, Part Five: More On Arrays In JScript .NET

As I was saying the other day, CLR arrays and JScript arrays are totally different beasts. It is hard to imagine two things being so different and yet both called the same thing. Why did the CLR designers and the JScript designers start with the same desire — create an array system — and come…

5

The JScript Type System, Part Four: JScript .NET Arrays

As I mentioned in an earlier entry, one of the major differences between JScript .NET and JScript Classic is that JScript .NET now supports optional type annotations on variables.  The number of built-in primitive types has also increased dramatically.  JScript .NET adds value types boolean, byte, char, decimal, double, float, int, long, sbyte, short, uint,…

1

The JScript Type System, Part Three: If It Walks Like A Duck…

A reader asks “can you explain the logic that a string is not always a String but a regexp is always a RegExp? What is the recommended way of determining if a value is a string?”   Indeed, you are correct:   print(/foo/ instanceof RegExp);             // true print(new RegExp(“foo”) instanceof RegExp); // true print(“bar” instanceof…

8

The JScript Type System, Part Two: Prototypes and constructors

A number of readers made some good comments on my article on JScript typing that deserve to be called out in more detail.   First, I was being a little sloppy in my terminology — I casually conflated static typing with strong typing, and dynamic typing with weak typing.  Thanks for calling me on that. …

16

What Is The Matrix?

I’m going to make a rare departure from technical stuff for a moment.  I’ve seen Matrix Revolutions twice in the last twelve hours, once in IMAX.    A number of people have asked me for an opinion.  To sum up in a spoiler-free manner:   First off, IMAX was better, though not enormously so.  (Oddly…


The JScript Type System, Part One

I thought I might spend a few days talking about the JScript and JScript .NET type systems, starting with some introductory material. Consider a JScript variable: var myVar; Now think about the possible values you could store in the variable. A variable may contain any number, any string or any object. It can also be…

14

Eval is Evil, Part Two

As I promised, more information on why eval is evil.  (We once considered having T-shirts printed up that said “Eval is evil!” on one side and “Script happens!” on the other, but the PM’s never managed to tear themselves away from their web browsing long enough to order them.)     Incidentally, a buddy of mine who…

6

A Parable

Once upon a time I was in high school. Ah, the halcyon days of my youth. One day I was sitting in class, minding my own business when the teacher said: “Does anyone have a thin metal ruler?” No answer. Apparently no one had a thin metal ruler. “No? How about a nail file?” No…

3

Eval is Evil, Part One

The eval method — which takes a string containing JScript code, compiles it and runs it — is probably the most powerful and most misused method in JScript. There are a few scenarios in which eval is invaluable.  For example, when you are building up complex mathematical expressions based on user input, or when you…

29