ufcpp-live / UfcppLiveAgenda

@ufcpp live streaming agenda
MIT License
24 stars 2 forks source link

Visual Studio 17.2 Preview 3, .NET 7 Preview 3 #56

Closed ufcpp closed 2 years ago

ufcpp commented 2 years ago

配信URL: https://www.youtube.com/watch?v=4TiCd5ov_WI

そんなに良さげな話ないかも…

Preview 4 (core/issues/7378)に期待? C# 的にも、17.3 で u8 リテラルとか入るみたいで次に期待? (runtime に先行して u8 リテラル使ってみた PR あり runtime/pull/67733)

なのでまた Language Design Meeting Notes 読みかなぁ…

LDM

こっちも細かい話が多め。

話されてた内容:

// C# 3.0 の頃からこんな感じのコード、有効
// Q. これ、static abstract/型引数に対してもできるべき?
// A. できるべきだとは思う。今できないのは意図的じゃない。でも、需要なさそうだし作業したくない
var x = from a in X where true select a;

static class X
{
    public static int Where(Func<int, bool> _) => 0;
}
public struct S
{
    int x = 1;
    int y;

    public S(int y) : this() // この :this() はどういう意味になるべき?
    {
    }
}
Console.WriteLine($"""{1}"""); // 1
Console.WriteLine($"""{{1}}"""); // これだけコンパイルエラー。認める?

Console.WriteLine($$"""{{1}}"""); // 1
Console.WriteLine($$"""{{{1}}}"""); // {1}

Console.WriteLine($$$"""{{{1}}}"""); // 1
Console.WriteLine($$$"""{{{{1}}}}"""); // {1}
ufcpp-live commented 2 years ago
// C# でも整数型引数はほしい時なくはない
struct FixedArray<T, int N>
{
    private T _items[N];
}

// 今、やっつけ大体案として…
var array = new FixedArray<int, object[,,,]>();
// new FixedArray<int, 4> のつもり
ufcpp-live commented 2 years ago
// generic attribute はいつの間にか requires preview features 外れてる。
[A<int>] // これは OK
[A<T>] // ダメ
[B(typeof(T))] // この時点でダメ
class X<T>
{
}

class AAttribute<T> : Attribute { }

class BAttribute : Attribute
{
    public BAttribute(Type t) { }
}
ufcpp-live commented 2 years ago
public readonly struct Int32
    : IAdditionOperators
{

}

// 別件として、associated type を考えてる
// self 制約を考えるのであればこれが先。
// associated type がいつになるのかわかんないので、当面、self type ない。
interface IAdditionOperators
{
    associated type T;
    abstract static T operator +(T x1, T x2);
}
ufcpp-live commented 2 years ago

Int32 苦行

IAdditionOperators<Int32, Int32, Int32>,
IAdditiveIdentity<Int32, Int32>
IBinaryInteger<Int32>
IBinaryNumber<Int32>
IBitwiseOperators<Int32, Int32, Int32>
INumber<Int32>
IComparable,
IComparable<Int32>
IComparisonOperators<Int32, Int32>
IEqualityOperators<Int32, Int32>
IEquatable<Int32>
IDecrementOperators<Int32>
IDivisionOperators<Int32, Int32, Int32>
IFormattable, IIncrementOperators<Int32>
IModulusOperators<Int32, Int32, Int32>
IMultiplicativeIdentity<Int32, Int32>
IMultiplyOperators<Int32, Int32, Int32>
IParseable<Int32>
ISpanFormattable,
ISpanParseable<Int32>
ISubtractionOperators<Int32, Int32, Int32>
IUnaryNegationOperators<Int32, Int32>
IUnaryPlusOperators<Int32, Int32>
IShiftOperators<Int32, Int32>
IConvertible,
IMinMaxValue<Int32>
ISignedNumber<Int32>
ufcpp-live commented 2 years ago
interface I
{
    public static bool operator ==(I x1, I x2) => true; // non-virtual は多分認めない
    abstract static bool operator ==(I x1, I x2); // 行けるようにするかも
    public virtual static bool operator ==(I x1, I x2) => true; // 行けるようにするかも
}
ufcpp-live commented 2 years ago
// C# 3.0 の頃からこんな感じのコード、有効
// Q. これ、static abstract/型引数に対してもできるべき?
// A. できるべきだとは思う。今できないのは意図的じゃない。
// ****でも、需要なさそうだし作業したくない****
var x = from a in X where true select a;

// こうなる↓
var x1 = X.Where(a => true);

static class X
{
    public static int Where(Func<string, bool> _) => 0;
}

interface I
{
    abstract static int Where(Func<string, bool> _);
}

void m<T>()
    where T : I
{
    // これがダメらしいよ。
    // (リスナー全員満場一致で「ダメでいいだろ」)
    var x = from a in T where true select a;
}
ufcpp-live commented 2 years ago
// Q. 以下のうち、エラーになる行をこたえよ
Console.WriteLine($"""{1}""");
Console.WriteLine($"""{{1}}""");
Console.WriteLine($$"""{{1}}""");
Console.WriteLine($$"""{{{1}}}""");
Console.WriteLine($$$"""{{{1}}}""");
Console.WriteLine($$$"""{{{{1}}}}""");
ufcpp-live commented 2 years ago
_ = @"""a"""; // これ、普通の verbatim だわ…