News for hackers. Stuff that matters.
Re:Microsoft takes .NET open source and cross-platform by jakevn on Wednesday November 12, 2014 @03:42PM (#8598013)
That's true.

A talented C# dev will need to know co/contravariance as well as implicits considering they also exist in C#.

In Scala, being familiar with these concepts is practically a necessity, though.

Re:Microsoft takes .NET open source and cross-platform by dragonwriter on Wednesday November 12, 2014 @06:04PM (#8598870)
> A talented C# dev will need to know co/contravariance as well as implicits considering they also exist in C#.

True for co/contravariance. For implicits, that depends on which implicits you are talking about.

Scala has:

* implicit conversion operators (these have existed in C# for some time, under the same name)

* implicit parameters (C# doesn't have an analog to these that I can think of)

* implicit classes (C# has an analog in classes providing extension methods, though the classes themselves are distinguished by a keywords as they are in Scala; in Scala, these are essentially syntactic sugar for creating a normal class and an implicit conversion from the extended class.)

Re:Microsoft takes .NET open source and cross-platform by jakevn on Wednesday November 12, 2014 @06:50PM (#8599090)
> implicit parameters (C# doesn't have an analog to these that I can think of)

C# allows default values for parameters, but it's not quite the same.

Example of C# default value for parameter:

  static void Addition(int a, int b = 42)  
  {  
    Console.WriteLine(a + b);  
  }

  Addition(4); // Prints 46  
  Addition(4, 5); // Prints 9
In Scala, the default (implicit) value has more complex rules.

Like C#, implicit parameters must come after non-implicit parameters (if any).

Unlike C#, the implicit value does not need to be defined in the signature. Also unlike C#, if you provide the value for one implicit parameter, you must provide the value for all implicit parameters.

Re:Microsoft takes .NET open source and cross-platform by dragonwriter on Wednesday November 12, 2014 @07:05PM (#8599152)
> C# allows default values for parameters, but it's not quite the same.

Right. Scala has C#-style default parameters as well, implicit parameters are a different (though very loosely related) thing.

Re:Microsoft takes .NET open source and cross-platform by hokkos on Wednesday November 12, 2014 @05:18PM (#8598642)
Can you give me examples of implicits in C# ? I am unable to see a parallel.
Re:Microsoft takes .NET open source and cross-platform by jakevn on Wednesday November 12, 2014 @05:53PM (#8598820)

  using System;
  
  public class Program
  {
  
  public class Person
  {
    private string _name;
    private int _age;
    
    public Person(string name, int age)
    {
      _name = name;
      _age = age;
    }
		
    public static implicit operator int(Person p)
    {
      return 42;
    }
  }
	
  public static void Main()
  {
    var person = new Person("Jim", 51);
    var number = 100;
    AdditionPrinter(person, number); // Prints 142
  }
	
  public static void AdditionPrinter(int a, int b)
  {
    Console.WriteLine(a + b);
  }
  
  }
Re:Microsoft takes .NET open source and cross-platform by seanmcdirmid on Wednesday November 12, 2014 @07:10PM (#8599171)
Also consider extension methods, which serve some of the same purpose as implicits in Scala.