Browse by Tags

Tagged Content List
  • Blog Post: 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 TypeScript. Long...
  • Blog Post: 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...
  • Blog Post: 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; for some undeclared variable...
  • Blog Post: 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...
  • Blog Post: 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. The...
  • Blog Post: 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 this...
  • Blog Post: 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...
  • Blog Post: 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 forums...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: Recursion, Part Five: More on CPS

    Suppose we wanted to write this by-now-familiar little function in continuation passing style: function treeDepth(curtree) { if (curtree == null) return 0; else { var leftDepth = treeDepth(curtree.left); var rightDepth = treeDepth(curtree.right); return 1 + Math.max(leftDepth, rightDepth); } } ...
  • Blog Post: Recursion, Part Four: Continuation Passing Style

    We're getting hung up on the stack management aspects of recursive programming. Why do we need a stack at all? What purpose does it serve? If you're like most developers, you probably learned about subroutines and functions at an early age. The idea is pretty straightforward. You stop what you're...
  • Blog Post: Recursion, Part Three: Building a Dispatch Engine

    There's a particular technique that I like to use to solve problems -- it doesn't always work, but when it does, it can produce programs of surprising elegance and power. The technique is this: if you have a specific problem to solve, solve a more general problem, and then your problem is just a special...
  • Blog Post: Recursion, Part Two: Unrolling a Recursive Function With an Explicit Stack

    That recursive solution is pretty cool, to be sure. But there is one big problem with it. Consider this Jscript program that puts a few more nodes into our tree from last time: function tree(value, left, right) { this.value = value; this.left = left; this.right = right; } for (var i = 1 ; i < 1500...
  • Blog Post: Recursion, Part One: Recursive Data Structures and Functions

    The first thing to wrap your head around is recursively defined data structures. Let's start with something simple. Think about the abstract idea of “list”. Most people think of a “list” as an ordered collection of “items”, one after the other, with a beginning and an end. That’s a very non-recursive...
  • Blog Post: Recursion, Part Zero

    I’ve mentioned recursive programming techniques several times over the years in this blog ( Topological Sort , How Not To Teach Recursion , Fibonacci Challenge , Recursion and Dynamic Programming , Sometimes Breadth Is Better Than Depth , and probably a few others). A lot of developers, particularly...
  • Blog Post: Scripting Type Library Constant Injection Performance Characteristics, Part One

    (Sorry about the title. I work for Microsoft; we like nouns .) Over a year ago now a reader noted in a comment to this posting that defining named constants using Const in VBScript or var in JScript is way, way faster than importing a type library. My empirical JScript testing showed that loading...
  • Blog Post: What is the relationship between global object enumerators, execution contexts, activation objects, variable objects and this?

    UPDATE: I am WRONG WRONG WRONG . Brendan Eich, the original creator of JavaScript, was kind enough to point out at great length that I was WRONG WRONG WRONG in my conclusions earlier today. Somehow I managed to miss the key section in the spec -- my search-fu is not all its cracked up to be apparently...
  • Blog Post: Bad Recursion Revisited

    We have internal email lists for questions about programming languages. Here's one that came across recently that I thought illustrated a good point about language design. An interview candidate gave the following awful implementation of the factorial function. (Recall that factorial is notated "n...
  • Blog Post: How Do Script Engines Implement Object Identity?

    I've talked a few times in this blog about the semantics of the equality operators in various languages. (Such as here , and here .) Recently a reader asked me how JScript implements object identity. That is, given two objects, how do we know if they are "the same object" or not? For the remainder...
  • Blog Post: Fun With Floating Point Arithmetic, Part Three

    I've been getting lots of mail, questions and pointers to interesting articles on some of the trials and tribulations of using floating point arithmetic correctly. Please do keep it coming! Though I am certainly no expert in this area, I'm happy to take a crack at any questions you might have. To sum...
  • Blog Post: Why do built-in JScript functions not appear in the typeinfo?

    A reader sent me an email over the weekend asking about some odd behaviour in the guts of the JScript engine. Unfortunately, they didn't include an email address that worked; I just got a bounce message back, Ben. Therefore I'll just answer the question here. To briefly describe the problem: the user...
  • Blog Post: Google Desktop On The Cheap, Part Zero

    Before I get started with my next series, two quick notes. First, at long last I had dinner with famed JOS poster (and east coast technical evangelist for my product, VSTO) Philo the other night, as he happened to be in Redmond. I'm pleased to report that he's as witty, urbane and opinionated in real...
  • Blog Post: Wherefore IDispatchEx?

    Quite a while back I said that I'd write a post describing why we invented IDispatchEx . I already covered the part about using it to probe the stack for security reasons, but what other reasons did we implement that thing? The documentation is pretty much accurate, but sparse in places. (According to...
  • Blog Post: Breadth is sometimes better than depth

    A while back the Scripting Guys blogged about using recursion to list all the files in a directory and all its subdirectories. Something that you'll notice about this very standard solution to this problem is that it is "depth first". That is, it lists the files like this: c:\xyz.txt c:\foo\bbb.txt c...
Page 1 of 4 (94 items) 1234