ufcpp-live / UfcppLiveAgenda

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

連休ボケ大丈夫ですか? #33

Closed ufcpp closed 3 years ago

ufcpp commented 3 years ago

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

連休中に書いてた記事の話と、「そろそろ休みボケ解消しようか」を目的とした配信。

GW 中に一応に レコード型 の話書いた。

C# 9.0 がらみの残タスク: https://github.com/ufcpp/UfcppSample/issues/297 残りは nint と関数ポインターだけのはず。

関数ポインター… たぶん一番使われるのはクロスプラットフォームの Native Interop (要は Xamarin との統合)と思われるものの、その作業が .NET 6 マイルストーンなので、利用箇所が少なすぎて紹介しづらい…

ufcpp-live commented 3 years ago

開幕から Java とか C++ な話にそれまくり。

C# にも int template ほしいという話あり…

GaloisField<_2> x;

interface INum { int Value { get; } }
struct _0 : INum { public int Value => 0; }
struct _1 : INum { public int Value => 1; }
struct _2 : INum { public int Value => 2; }
struct _3 : INum { public int Value => 3; }
struct _4 : INum { public int Value => 4; }
struct _5 : INum { public int Value => 5; }
struct _6 : INum { public int Value => 6; }
struct _7 : INum { public int Value => 7; }
struct _8 : INum { public int Value => 8; }

struct GaloisField<T>
    where T : INum
{
}
ufcpp-live commented 3 years ago

C# にも ownership モデルほしいんだけど…

一応、non-copyable なら…

https://ufcpp.net/blog/2017/12/noncopyable/

最近は公式に使ってる: https://github.com/dotnet/roslyn-analyzers/pull/3420

ufcpp-live commented 3 years ago
using System;

var x = new X();

using (x) { } // x のコピーかかってる

Console.WriteLine(x.Value); // 0

struct X : IDisposable
{
    public int Value;

    public void Dispose()
    {
        ++Value;
    }
}
ufcpp-live commented 3 years ago
using System;

var x = new X();

using (x) { } // x のコピーかかってる

Console.WriteLine(x.Value); // 0

ref struct X
{
    public int Value;

    public void Dispose()
    {
        ++Value;
    }
}
ufcpp-live commented 3 years ago

関数ポインターの記事書くの、実例がまだ少なくて困ってる話

実例あった: https://github.com/dotnet/runtime/pull/39752