Browse by Tags

Tagged Content List
  • Blog Post: Precision and accuracy of DateTime

    The DateTime struct represents dates as a 64 bit number that measures the number of “ticks” since a particular start date. Ten million ticks equals one second. That’s a quite high degree of precision . You can represent dates and times to sub-microsecond accuracy with a DateTime, which is typically more...
  • Blog Post: As Timeless As Infinity

    User: Recently I found out about a peculiar behaviour concerning division by zero in floating point numbers in C#. It does not throw an exception, as with integer division, but rather returns an "infinity". Why is that? Eric: As I've often said, "why" questions are difficult for me to answer. My first...
  • 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: Reading Code Over the Telephone

    In my youth I once attended a lecture given by Brian Kernighan on the subject of code quality, which was very influential on my attitudes towards writing legible code. One of the things that Kernighan recommended was to endeavour write code that was so clear that it could be easily read over the phone...
  • Blog Post: Do Not Call IsBadFooPtr, Indeed

    Here’s a story that I said a long time ago that I was going to tell you all , and then promptly forgot about it. Raymond Chen’s blog entry today reminded me of it, because this is the story of how I found out the hard way that IsBadFooPtr is bad, bad, bad. Those of you who have been following releases...
  • 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: 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: 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: 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: 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: Binary Files and the File System Object Do Not Mix

    OK, back to scripting today. But before I get back to scripting issues, one brief correction. An attentive reader noted that "The Well-Tempered Clavier" was in fact designed to sound good on a "well tempered" instrument, not an "equally tempered" instrument. The difference is that a "well" temperament...
  • Blog Post: VBScript Quiz Answers, Parts Eleven and Twelve

    11) X and Y are both Booleans. Which of the following always assigns True ? Why? (a) Z = Not X Or Y = X Imp Y (b) Z = X Imp Y = Not X Or Y (c) Z = X Eqv Y = Not X XOr Y (d) Z = Not X XOr Y = X Eqv Y (a) assigns False if X and Y are both False . The others assign True no matter what X and Y are...
  • Blog Post: VBScript Quiz Answers, Parts Nine and Ten

    9) Which of these statements is syntactically legal? Why? (a) Const Z = -+-+-+-10 (b) Const Y = 2 + 2 (c) Const X = .1e310 (d) Dim W(+10) (a) is legal. The rest are illegal. (a) is legal because you can put as many unary positive or negative operators on top of a constant as you want, so long as it's...
  • Blog Post: VBScript Quiz Answers, Part Eight

    8) Which of these programs is syntactically legal? (a) Class Bar Function Foo End Function Function Foo End Function End Class (b) Class Bar If Blah Then Function Foo End Function Else Function Foo End Function End If End Class (c) If Blah Then Function Foo End Function Else Function Foo End Function...
  • Blog Post: VBScript Quiz Answers, Part Seven

    Before I get into today's entry, a brief editorial comment: Pestilence is a frickin' pain in the rear . Famine was no problem at all, Rodney didn't touch me once, and Master Kaen fell to my powerful fists, but two Amulets of Life Saving, one Wand of Death and four potions of full healing were insufficient...
  • Blog Post: VBScript Quiz Answers, Part Six

    This question was designed to highlight some of the oddities in VBScript's rules for what makes a legal identifier. 6) Which of the following are syntactically legal? Why? (a) Explicit Error (b) For[i=1]=[To[1]To[1] (c) For i =.For To Step Step Step (d) For Each Each In In (d) is illegal, the rest are...
  • Blog Post: VBScript Quiz Answers, Part Five

    5) Which of the following statements are guaranteed to never print False ? Assume that On Error Resume Next is in effect. (a) If x = x Then Print True Else Print False (b) If CStr(x) = CStr(x) Then Print True Else Print False (c) If True Or x Then Print True Else Print False (d) x = True : If x Then...
  • Blog Post: VBScript Quiz Answers, Part Four, Plus, More Trivia!

    Last night I gave away more copies of my book at our Visual Studio Tools for Office developer lab, but this time I made the trivia questions a whole lot easier. I played five rounds of "Odd Man Out" -- you know, like from Sesame Street. One of these things is not like the other, one of these things just...
  • Blog Post: VBScript Quiz Answers, Part Three, and RegEx Memory Leak

    Co-Winner Nicholas Allen's prize is en route to his home now. Steven Bone, I need your mailing address still. Before I give the answer to #3, a quick note. NTBUGTRAQ is reporting a memory leak in the VBScript regular expression parsing code. I took a quick glance at the sources, and sure enough, there...
  • Blog Post: VBScript Quiz Answers, Part Two

    When you're getting close to shipping a beta for a big product, the dev team is either insanely busy tracking down last-minute issues, or deathly bored. This week was one of the insanely busy weeks! Lots of late nights. It looks like next week should be a little calmer though. Anyway, on with the quiz...
  • Blog Post: VBScript Quiz Answers, Part One

    There were a grand total of eight entries to my VBScript quiz -- I think I made it too hard! Congratulations to Steven Bone and Nicholas Allen, who both got all twelve right, with more-or-less correct explanations of what was happening here. Guys, send me your addresses and I'll send you both autographed...
  • Blog Post: Win Fabulous Prizes!

    I want to do a long -- potentially very long -- series of blog articles about the fundamental theoretical nature of formal computer languages, and the practical problems in producing compilers for them. To kick this off in a lighthearted way on a Friday, here's a quiz that shows some of the weird "corner...
Page 1 of 4 (80 items) 1234