Martin Baulig, super hacker

by Miguel de Icaza

Martin has been working for the past couple of weeks on fixing a bug in the Mono C# compiler: how to properly compile an anonymous method inside a generic method.

The problem started with an innocent looking program:

        delegate void Foo ();

        class X
                static void Hello<U> (U u)
                { }

                static void Test<T> (T t)
                        Foo foo = delegate {
                                Hello (t);

The issue is that when we generated the anonymous method for "foo", we had to turn the "T" generic method parameter into a generic *class* parameter:

  .class nested private auto ansi sealed beforefieldinit 'AnonHelp<0>'
    extends [mscorlib]System.Object
     .field  assembly  !0 'p:t'

The code to cope with this in the compiler was fairly ugly, and Martin embarked on fixing the design internals at the end of July. We originally thought that there were two solutions: an elegant solution that required some refactoring and an ugly hack that basically accessed System.Reflection.Emit directly and poked at these internals from the anonymous method code path.

I have never quite liked what I did with the implementation of anonymous methods; I have tried to bounce the ideas off a few people to try to get their feeling on how to redo this code. I explained the design to Federico and Gonzalo hoping to get some feedback on the bugs and to clarify my own thoughts.

So to make a long story short, I did not like what was going on in the internals of the compiler; and in addition there are some annoying side effects and various constructs that crash the compiler when nested anonymous methods are used or when iterators and anonymous are mixed.

On Friday, Martin sent his weekly status report where he officially has removed my design mistakes. He has eliminated CaptureContext's from the compiler, and has eliminated the special-cases that coped with captured variables in the compiler --another part piece of code that worked, but was far from elegant--.

The new code that Martin has written replaced chunks of code that has bugged me for more than a year, so these are great news.

The patch is available here

In addition, cleaning up this code is essential as C# 3.0 will make extensive use of this infrastructure as part of the new lambda function support (This is because in C# 3.0 it is very natural for developers to create nested lambdas and anonymous methods, something that was more of a curiosity with the C# 2.0 syntax).

Btw, Martin just had a birthday, and he likes chocolates ;-)

Posted on 02 Sep 2006

A To-Do list for Bittorrent Sharp

by Miguel de Icaza

Alan has updated the list of TODO activities for BitSharp.

Posted on 02 Sep 2006

BitTorrent, half a tone up

by Miguel de Icaza

This year, during the summer of code three students worked on Bittorrent support for Mono/.NET. Each one was in charge of an independent piece: a bittorrent downloading (Alan), a tracker (Gregor) and the GUI (Piotr).

The code has now moved from our incubator repository to the public and it is available on SVN or you can get a tarball of it.

The code is licensed under the terms of the MIT X11 license, which means, anyone can embed it anywhere.

If you make fixes or improve the code, it would be nice for you to contribute those back. Let the sharp bitorrenting begin!

Screenshots will come later.

Posted on 01 Sep 2006

Authoring File Systems with Mono on Linux

by Miguel de Icaza

On Linux it is possible to write user-level file system by using FUSE, a toolkit to write user-space tools that can be mounted as file systems.

There is a whole scene of Fuse developers, to satisfy the most unique tastes in file system needs. Cryptographic file systems, gmail-as-a-backing-store, and of course a Wikipedia file system.

Jon Pryor has released Mono and FUSE bridge: Mono.Fuse. With Mono.Fuse it is possible to author file system extensions with Mono using any of the libraries or languages supported by Mono.

To create a file system with Mono.Fuse, you must create a class that derives from Mono.Fuse.FileSystem, like this:

  using Mono.Fuse
  class TypeNavigator : FileSystem {

      static void Main (string [] args)
          using (TypeNavigator t = new TypeNavigator ()){
	      t.MountPoint = args [0];
	      t.Start ();


Then you need to implement a couple of methods, you override the directory reading and attribute fetching methods like this:

  protected override Errno OnReadDirectory (string path, [Out] out string[] paths, OpenedFileInfo fi)

  protected override Errno OnGetFileAttributes (string path, ref Stat stbuf)

I wrote a small file system to browse assemblies, you can get the source here.

To run my toy file system, do this:

	$ mono fuse.exe /tmp/u

That will get the file system going (currently you need the Mono.Fuse.dll library in the same directory where fuse.exe lives, and the in your library path).

With this, you can browse the types in your favorite assemblies from the shell (or for the less manly hackers in my readership: a file manager) like this:

	$ ls /tmp/u/mscorlib
	$ ls /tmp/u/mscorlib/Mono.Security.Cryptography.SymmetricTransform
	CanReuseTransform               GetHashCode          OutputBlockSize
	CanTransformMultipleBlocks      get_InputBlockSize   ToString
	Equals                          get_OutputBlockSize  TransformBlock
	get_CanReuseTransform           GetType              TransformFinalBlock
	get_CanTransformMultipleBlocks  InputBlockSize


Once you are done with the exciting world of browsing your assemblies with ls and cd you can umount your file system like this:

	$ fusermount -u /tmp/u

Very nice work Jon!

Posted on 01 Sep 2006

Mexico Mess

by Miguel de Icaza

I had not been writing about the state of affairs in Mexico for a while.

Things are not looking any more positive now.

A quick recap: the elections results are contested on many grounds, and various groups have put forward evidence that the results were tampered with (My father, has put together a number of academic studies at the results).

Anyways, the PRD has taken over some portions of the city and "camped out" and there are some beginnings of civil resistance.

The electoral tribunal has turned down the request to revisit/recount the contested ballot boxes which could very likely change the election results.

The government in the meantime has been training some para-military forces, not directly linked to the government and which is supposed to infiltrate resitance groups. These had been barred from existance in Mexico after two massacres, the 1968 Tlatelolco Massacre (lead by the military) and the 1971 Corpus Christy massacre (lead by these paramilitary groups).

With the vote by vote recount request ruled out, the civil resistance seems more imminent.

Fox's government is busy getting a new paramilitary group ready for action for the upcoming State of the Union.

Very much like the 1971 paramilitary group, the new group is supposed to "blend" with the crowd; They will not be wearing uniforms, have been asked to keep their hair long, and dress casually.

Posted on 31 Aug 2006

Visual Basic in Mono: VBNC is Self Hosting!

by Miguel de Icaza

Rolf has just commited the patch to make VBNC self-hosting, the goal that he was aiming for as part of the Google Summer of Code.

VBNC is Rolf's Visual Basic 8 compiler written in Visual Basic 8, the one that we are using to replace Mono's current mbas compiler.

From his patch:

	2006-08-19  Rolf Bjarne Kvinge 
		* Bugfixes: The compiler can now bootstrap itself!!!


Congratulations Rolf!

In other news, the new VB runtime has been checked into SVN, in the module `mono-basic', this runtime is also written in VB8 unlike our previous attempt which was built on C#.

Rolf's compiler is able to build this new runtime as well.

The details of the new upgrade in Basic handling in Mono are here.

Posted on 19 Aug 2006

Wiki Dot Com

by Miguel de Icaza

A couple of friends of mine, Mono contributors, are working at Mindtouch, a new startup doing very nice Wikis.

They are providing the engine behind Wiki.Com. You can create your own Wiki there.

They are running DekiWiki a Wiki based on MediaWiki (the engine behind Wikipedia) that has been adapted to run on top of Dream.

Posted on 19 Aug 2006

MonoTorrent: early review

by Miguel de Icaza

I started my early review of the MonoTorrent code for the Summer of Code (from Alan McGovern). It works!

The code is available from our incubator repository, once the summer of code is over, we will move it to the public repository.

This is a screenshot of the command line version:


I know.

Posted on 18 Aug 2006

A month with Wobbly Windows

by Miguel de Icaza

Some people have said that Wobbly windows do not improve productivity, and that its unnecessary candy for the Linux desktop. I initially thought I would not be able to stand wobbly windows for long.

I was wrong. Wobbly windows are now an integral part of my computing experience.

Non wobbly systems feel arcane to me now. If a window does not become transparent when I drag it, I get the feeling am using a cell phone instead of a computer.

Also, wobbly windows are great when you are waiting for an "svn update" to complete, or Evolution to import email, its great for stress relief.

Posted on 18 Aug 2006


by Miguel de Icaza

There is now a community site for F# users at cs.HubFS.Net, some screenshots of the demos that were shown at Lang.Net are here, here and here.

Posted on 17 Aug 2006

« Newer entries | Older entries »