Browse by Tags

Tagged Content List
  • Blog Post: The void is invariant

    [UPDATES below] A while back I described a kind of variance that we’ve supported since C# 2.0. When assigning a method group to a delegate type, such that both the selected method and the delegate target agree that their return type is a reference type, then the conversion is allowed to be covariant...
  • Blog Post: Iterators at the Summer Games

    Ed "Scripting Guy" Wilson was kind enough to ask me to be a guest commentator at this years Summer Scripting Games , which have just completed. I've been working on a series for this blog about some unusual cases in the design of the "iterator block" feature in C# 2.0; this bit from my commentary...
  • Blog Post: It Already Is A Scripting Language

    My recent post about the possibility of considering maybe someday perhaps adding "top level" methods to C# in order to better enable "scripty" scenarios generated a surprising amount of immediate emphatic pushback. Check out the comments to see what I mean. Two things immediately come to mind. ...
  • 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: Bug Psychology

    Fixing bugs is hard. For the purposes of this posting, I’m talking about those really “crisp” bugs -- those flaws which are entirely due to a failure on the developer’s part to correctly implement some mechanistic calculation or ensure some postcondition is met. I’m not...
  • Blog Post: A Book By Any Other Name Would Smell As Sweet

    As you might have gathered from my previous posts on the subject, I occasionally edit technical books as a hobby. It’s nice having a hobby that pays money instead of costing money. And I always learn something from every book. Many years ago, on one of my first editing gigs, the editor asked me my...
  • Blog Post: Human sacrifice, dogs and cats living together, mass hysteria! and thread model errors!

    Reader Shaka comments on my post about error messages that "catastrophic failure" really does take the cake as being a terrible error message. I fondly remember the first time I saw "catastrophic failure" as an error message. I was an intern, running the build lab for Visual Basic for Applications...
  • 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: 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: Implementing Event Handling, Part One

    Back in February I posted a bit about how script hosts such as Windows Script Host dynamically hook up event sources (objects) to event sinks (chunks of script that run when the event fires.) It has become apparent from some questions I've received recently that it would be helpful to have a more detailed...
  • Blog Post: 250% of what, exactly?

    I just got a question this morning about how to take two collections of items and determine how many of those items had the same name. The user had written this straightforward but extremely slow VBScript algorithm: For Each Frog In Frogs For Each Toad In Toads If Frog.Name = Toad.Name Then SameName...
  • Blog Post: VBScript Default Property Semantics

    Here’s a question I recently got about VBScript, where by "recently" I mean August 28th, 2003. This code works just fine: Set myObject = CreateObject("myObject") myObject.myName = "Eric" WScript.Echo myObject ' myName is the default property, so prints "Eric" But myObject = "Robert" doesn't set...
  • 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 Three

    We’ve got a system that meets all our needs for disambiguating hierarchical constants through partial or full qualification. (In the event of a collision between an enumerated type name and a value in a given library, the type name wins so that full qualification can work.) But what about the performance...
  • Blog Post: Scripting Type Library Constant Injection Performance Characteristics, Part Two

    Script developers can declare constants, variables, functions and classes at global scope by writing the appropriate lines of code. Script hosts (Internet Explorer, ASP, WSH, etc) however can only add objects to the script engine’s global scope. For practical purposes, it’s as though the host creates...
  • 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...
Page 1 of 8 (189 items) 12345»