Friday, July 25, 2014

Thursday, November 14, 2013

Tuesday, October 29, 2013

Tuesday, August 20, 2013

Boost at nuget.org

It's unofficial but it works https://www.nuget.org/packages/boost/. For Visual Studio 2012, supported platforms: Win32 and x64.

It's huge 235Mb and takes about half an hour to install.

  1. Open your C++ project. Or create a new one.
  2. Open Tools | Library Package Manager | Manage NuGet Packages for Solution....
  3. Search for "boost" in Online | NuGet Official Package Source (Include Prerelease).
  4. Press the Install button.
  5. Wait for about 10 minutes.
  6. Select your C++ project and press Ok.
  7. Wait for another 10 minutes.
  8. Close the dialogs.
  9. Include some boost header files. For example: #include <boost/atomic.hpp>
  10. Build the project.

Update

The updated boost package doesn't contain compiled libraries (.lib/.dll) any more. Now it's only 15Mb. I've created separate packages for the boost compiled libraries:

Sunday, February 13, 2011

Nemerle at Wikipedia.

The article about Nemerle has been removed from Wikipedia as a non-notable programming language.

Tuesday, February 1, 2011

INumeric policy.

Policies:
interface INumericPolicy<T>
{
    T Zero();
    T Add(T a, T b);
    ...
}

class All: INumericPolicy<int>, INumericPolicy<long>, ...
{
    ...
    public static All P = new All();
}
User's algorithms:
static class Algorithms
{
    public static T Sum<P, T>(this P p, params T[] a)
        where P: INumericPolicy<T>
    {
        var r = p.Zero();
        foreach(var i in a)
        {
            r = p.Add(r, i);
        }
        return r;
    }

    ...
}
Usage:
int i = All.P.Sum(1, 2, 3, 4, 5);
long l = All.P.Sum(1L, 2, 3, 4, 5);

Monday, January 31, 2011

.NET/C# 5 wish list

  1. Merge WPF and Silverlight. .NET Framework and .NET Compact Framework. It would be better to have just different profiles of framework like (.NET client profile) instead of different frameworks.
  2. Non-nullable references
    string! x = "xxx";
    
  3. Discriminated unions:
    union MyUnion: Enum
    {
        case Enum.Red: RedClass;
        case Enum.Green: GreenClass;
        ...
    }
    
  4. INumeric interface for standard numeric types.
    struct UInt32: INumeric<UInt32>
    {
    ...
    }
    
  5. Fixed size arrays
    byte[10] x;
    
  6. Operator extensions (syntax sugar):
    public static class Extensions
    {
        public static T operator+ <T>(T a, T b) where T: INumeric<T>
        ...
    }
    
  7. Polymorphic up cast:
    class A: B { ... }
    ...
    new A() up B
    
    Update: No needs any more. Solution:
    public static class Extension
    {
        public static T UpCast<T>(T derived)
        {
            return derived;
        }
    }
    
    Example:
    new B().UpCast<A>()
    
  8. Force use 'using' keyword for some classes.
    using class My: IDisposable
    {
        ....
    }
    
    ...
    
    // Ok.
    using(var my = new My())
    {
    }
    
    // Compilation error.
    {
     var my = new My();
    }
    
    // Ok.
    return new My();
    
  9. Units of measurements. As in F# http://msdn.microsoft.com/en-us/library/dd233243.aspx.
  10. Named code blocks.
    code Block
    {
      foreach(var x in M)
      {
        foreach(var y in x)
        {
          if(y)
            break Block; 
        }
      }
    }
    
  11. A reference to an anonymous delegate inside the delegate.
    Control.Selected += (s, e) =>
    {
        ...
        Control.Selected -= this function;
    }