Tuesday, February 7, 2012

Library hide and seek

So today I took some time to start playing with the IO library in Dart. Right off the bat I started running into problems. First off, I'm running Linux 64-bit and I'm using the latest integrated version of the IDE and SDK (Build 3934). Taking a look into the SDK I do see the IO libraries and such so I couldn't wait to get started. My first little script just spawns a new process running and displays the results. In this case in particular I'm spawning an snmpget command to run a quick and simple snmp query.

So I fire off my quick and dirty little script to see if I can get any output. I save my file and... err what what? The editor is giving me a nasty little error. Right there on line one of all places (my library declaration), a few other errors follow as well.
File not found: dart:io

A little further down is:
Multiple markers at this line
  - no matching constructor for Object
  - cannot find type Process

This line is where I make my new Process object using new Process.start(). Based on the first error, I gather that this line is generating an error because the IDE isn't recognizing any class called Process for me to create a new object from so it's trying to use the base Object class, which doesn't contain a named constructor called 'start'.

I mess around in the IDE to verify that the SDK libraries are available and that it is seeing the SDK as installed. Yeah, everything seems hunky-dory there. And... wait... my library panel is displaying the dart:io library right there in the left-hand pane. Something here doesn't seem right at all. I do a quick search in the dartbugs but don't find anything. So I came up with the following quick trial case and submitted a bug report.
#import("dart:io");

void main() {
  print("Hello World");
}

Save the above in the IDE and you should see the error generated at line 1. As I mentioned, I filed a bug report: Issue 1577. At first I thought that would be the end of my trials today, however I hit the run button anyways and low and behold the console is showing expected output. So while the IDE isn't recognizing the library in the editing pane, it is recognizing it in the libraries (though showing errors in it none-the-less) and the dart VM does run the code as expected. Excellent maybe I will get to do some testing after all!

Continued in INs and OUTs of IO.

No comments:

Post a Comment