Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
genericsの人気記事 40件 - はてなブックマーク
[go: Go Back, main page]

並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 40 件 / 40件

新着順 人気順

genericsの検索結果1 - 40 件 / 40件

genericsに関するエントリは40件あります。 golanggoprogramming などが関連タグです。 人気エントリには 『Go言語のジェネリクス入門』などがあります。
  • Go言語のジェネリクス入門

    Go1.18は2022年3月にリリースされました。このリリースはGo言語へのジェネリクスの実装を含んでいます。 この記事ではできるだけ最新の仕様と用語法にもとづいてジェネリクスの言語仕様について解説していきます。 更新履歴 2024/01/03: Go1.21(2023-08-08)でcmpパッケージが標準ライブラリに追加されたことに対応しました。 2023/02/23: Go1.20(2023-02-01)のcomparableの仕様変更に対応しました。 次の関連資料があります: The Go Blog - All your comparable types Griesemer氏によるGo公式ブログです。 Go言語のBasic Interfaceはcomparableを満たすようになる(でも実装するようにはならない) 上記の内容に対する筆者の解説記事です。Go1.20リリース前に書いたの

      Go言語のジェネリクス入門
    • Goのジェネリクス徹底理解

      1. ジェネリクスなしでの開発 ジェネリクスが導入される前に、異なるデータ型をサポートするジェネリック関数を実装するためにいくつかのアプローチがありました。 アプローチ1: 各データ型に対して関数を実装する このアプローチは、極めて冗長なコードと高い保守コストをもたらします。いかなる変更も、すべての関数に対して同じ操作を行う必要があります。さらに、Go言語は同じ名前の関数のオーバーロードをサポートしていないため、外部モジュールからの呼び出しにこれらの関数を公開するのも不便です。 アプローチ2: 最も広い範囲のデータ型を使用する コードの冗長性を避けるために、別の方法は最も広い範囲のデータ型を使用することで、つまりアプローチ2です。典型的な例はmath.Maxで、これは2つの数のうち大きい方を返します。様々なデータ型のデータを比較できるように、math.MaxはGoの数値型の中で最も広い範囲

        Goのジェネリクス徹底理解
      • Go言語がGenericsを導入、過去最大の変更となる「Go 1.18」正式版リリース

        Googleが中心となってオープンソースで開発されているGo言語の最新版となる「Go 1.18」正式版がリリースされました。 Go go1.18 is released! Release notes: https://t.co/UFumhMjcOL Download: https://t.co/fnDCVVhJXK#golang pic.twitter.com/uWNSy5V7nv — Go (@golang) March 15, 2022 ブログ「Go 1.18 is released!」によると、Go 1.18は、「massive release that includes new features, performance improvements, and our biggest change ever to the language.」(新機能、性能改善、そして過去最大の変更の変

          Go言語がGenericsを導入、過去最大の変更となる「Go 1.18」正式版リリース
        • Golang GenericsでREST APIを作る - Nature Engineering Blog

          Go 1.18が出てしばらく経ちました。みなさんGenerics使っていますか? @maaashです。 これは Nature Engineering Blog祭 の2日目の記事です。 祭り 最初は歓喜し、mapやfilter的なfor文を少しずつgithub.com/samber/loに切り替えたり、 internalなsliceパッケージを作ってみたり。 ですが心のどこかで欲求不満が蓄積されていくのを感じていました。 使い尽くしていないのでその真価が理解できていなくて物足りないような、 こんなに面白いおもちゃが与えられたのに遊び尽くしていないような感覚です。 Genericsを使ったコードを書きたい!と思いながら日々の業務でREST APIを書いていると、、 あれ、これはかの When To Use Genericsの結論にある: If you find yourself writing

            Golang GenericsでREST APIを作る - Nature Engineering Blog
          • Go: A Documentary

            The historical release notes may helpful for general information: doc/go1release Go Release History doc/go1prerelease Pre-Go 1 Release History doc/go0release Weekly Release History (Before Go 1) Language Design General design/go0initial Rob Pike, Robert Griesemer, Ken Thompson. The Go Annotated Specification. Mar 3, 2008. design/go0spec0 The Go Programming Language. Language Specification. Mar 7,

            • TypeScript: <T>の書く位置チートシート - Qiita

              Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

                TypeScript: <T>の書く位置チートシート - Qiita
              • Golang の Generics で使いたいものは大体 samber/lo にあった話 - Qiita

                はじめに 本記事は Go Advent Calendar 2022 の18日目の記事です。 Generics を使った関数でやりたかったことが、samber/lo に大体揃ってたという話をします。 すでに自前で書いてた関数もいくつかあったのですが、このライブラリを知り置き換えていったという体験談です。 ※結果的に「samber/lo のなかでこの辺り使えるかも」というものを私の独断と偏見でピックアップする記事になってます。 samber/lo とは samber/lo は 16日目のアベンドカレンダーの記事 でも取り上げられていまして、そこから説明を引用させていただきました。 samber/loは,多種多様な便利関数を提供するパッケージです。 JavaScriptのライブラリのLodashライクであるとREADMEにも記載があります。 個人的には大好きなパッケージでして,Map,Filte

                  Golang の Generics で使いたいものは大体 samber/lo にあった話 - Qiita
                • 部分型における変性と極性 - なぜScalaの変性は+や-で指定するのか - 貳佰伍拾陸夜日記

                  この記事はScala Advent Calendar 2022の19日目です. Scalaではジェネリック型の変性(variance)は+や-で指定しますが, 他の言語(たとえば, C#, Kotlin)ではoutやinだったりします. この記事では変性の意味を整理して, なぜScalaでは+/-の記号を使うのか説明します. 追記ただし, ここで説明している内容は基本的にC#やKotlinでも成立する(はずな)ので「なぜこれらの言語では+/-の記号を使わないのか」を説明するものではありません. 個人的には+/-の方がわかりやすいと思うし, out/inの記法は扱っている概念が簡単であるかのような誤解を生む(悪く言えば騙す)のでどちらかと言うと嫌いです. 発端 こういう話題がありました. Scala は共変が + で、反変が - なので理論重視? なのに対して、Kotlin と TypeSc

                    部分型における変性と極性 - なぜScalaの変性は+や-で指定するのか - 貳佰伍拾陸夜日記
                  • GoのGenerics関連プロポーザル最新状況まとめと簡単な解説

                    本記事では、GoのGenerics関連のProposal一覧のまとめと、簡単な解説を行います。 内容については随時更新を行います。 (本記事の内容をGo 1.17 リリースパーティーにて発表しました。) Generics関連のProposal一覧 (2022/2/3 更新) GoのGitHub Issueと、Gerritから見付けたGenerics関連のProposalを表にまとめました。 Proposal Status Author GitHub Issue Design Doc / Gerrit

                      GoのGenerics関連プロポーザル最新状況まとめと簡単な解説
                    • An Introduction To Generics - The Go Programming Language

                      The Go 1.18 release adds support for generics. Generics are the biggest change we’ve made to Go since the first open source release. In this article we’ll introduce the new language features. We won’t try to cover all the details, but we will hit all the important points. For a more detailed and much longer description, including many examples, see the proposal document. For a more precise descrip

                        An Introduction To Generics - The Go Programming Language
                      • GitHub - samber/lo: 💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)

                        You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                          GitHub - samber/lo: 💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)
                        • ジェネリクス引数の構文的曖昧性まとめ

                          ジェネリクスを持つ多くの言語では括弧の種類が足りなかったり、既存の文法との互換性を保つために <> をジェネリクス引数に使っている。この文字は比較演算子やシフト演算子にも使われるため、多くの場合は構文的曖昧性の問題がある。 // ジェネリクス引数 (convert<int, string>(number)) // 比較演算子 (score < MAX_SCORE, score > (MIN_SCORE)) 各言語でこの問題をどのように解決しているか調べる。 関連する問題として < > を含むトークン (<<, >> など) をどう分割するかという問題があるが、こちらは本スクラップでは扱わない。

                            ジェネリクス引数の構文的曖昧性まとめ
                          • Go1.17beta1でGenericsに触れてみた - oinume journal

                            Go1.17beta1がダウンロードできるようになったので、Generics(Type Parameters)でStackを書いて軽く遊んだメモ。 Generics (Type Parameters)について 最新の仕様のProposalは以下を見ると良い。 実際にどんな感じのコードになるのかは、GitHubのdev.typeparams branchのコードを見ると良さそう。 Go1.17beta1のダウンロード 普段使っているgoコマンドから以下のようにGo1.17beta1をダウンロードできる。 $ go get golang.org/dl/go1.17beta1 $ go1.17beta1 download これで ~/sdk/go1.17beta1 にインストールされる。 FYI: Goは標準の機能で複数のバージョンをインストールできる。より詳しくは以下のドキュメントを読むと良い

                              Go1.17beta1でGenericsに触れてみた - oinume journal
                            • Go 1.18 の Generics を使ったキャッシュライブラリを作った時に見つけた tips と微妙な点

                              GitHub にコードを上げてます。 2021-11-17 時点で Go の Generics の機能を使ったキャッシュライブラリはおそらくないでしょう。Generics を使った例の一つとして参考にしてください。 Star をくれると大喜びします。 本記事ではこのキャッシュライブラリを作ってみて Generics に対して気が付いた点と発見した tips や微妙だった点を紹介していきます。 もし Go の Generics って何ができるんだっけ?となっている方は是非こちらの記事にも目を通してみてください。 any でゼロ値を返す これは @syumai さんから教えてもらった tips です。 次のような any と error を返すコードをよく書くことになるでしょう。関数内で error が発生した時に今までゼロ値と error を返すコードを記述していたはずですが、ちょっと頭を捻

                                Go 1.18 の Generics を使ったキャッシュライブラリを作った時に見つけた tips と微妙な点
                              • Goのジェネリクスを活用する

                                Go勉強会 #1 #BuySell_Go (2023/5/24) https://buysell-technologies.connpass.com/event/283768/

                                  Goのジェネリクスを活用する
                                • Go 1.18 is released! - The Go Programming Language

                                  Today the Go team is thrilled to release Go 1.18, which you can get by visiting the download page. Go 1.18 is a massive release that includes new features, performance improvements, and our biggest change ever to the language. It isn’t a stretch to say that the design for parts of Go 1.18 started over a decade ago when we first released Go. Generics In Go 1.18, we’re introducing new support for ge

                                    Go 1.18 is released! - The Go Programming Language
                                  • Go Generics 超入門 / Kyoto.go Remote #28 LT会 (2022/02/23)

                                    2022/02/23のKyoto.go Remote #28 LT会 登壇資料です。 https://kyotogo.connpass.com/event/238059/

                                      Go Generics 超入門 / Kyoto.go Remote #28 LT会 (2022/02/23)
                                    • Generics can make your Go code slower

                                      🚧 Pardon our dust while we transition our blog to our new website. Go 1.18 is here, and with it, the first release of the long-awaited implementation of Generics is finally ready for production usage. Generics are a frequently requested feature that has been highly contentious throughout the Go community. On the one side, vocal detractors worry about the added complexity. They fear the inescapabl

                                        Generics can make your Go code slower
                                      • Crimes with Go Generics

                                        Queue[T] To start things out, let's show off a problem in computer science that is normally difficult. Let's make a MPMS (multiple producer, multiple subscriber) queue. First we are going to need a struct to wrap everything around. It will look like this: type Queue[T any] struct { data chan T } This creates a type named Queue that takes a type argument T. This T can be absolutely anything, but th

                                        • Go 1.26 is released - The Go Programming Language

                                          The Go Blog Go 1.26 is released Carlos Amedee, on behalf of the Go team 10 February 2026 Today the Go team is pleased to release Go 1.26. You can find its binary archives and installers on the download page. Language changes Go 1.26 introduces two significant refinements to the language syntax and type system. First, the built-in new function, which creates a new variable, now allows its operand t

                                            Go 1.26 is released - The Go Programming Language
                                          • Tutorial: Getting started with generics - The Go Programming Language

                                            This tutorial introduces the basics of generics in Go. With generics, you can declare and use functions or types that are written to work with any of a set of types provided by calling code. In this tutorial, you’ll declare two simple non-generic functions, then capture the same logic in a single generic function. You’ll progress through the following sections: Create a folder for your code. Add n

                                              Tutorial: Getting started with generics - The Go Programming Language
                                            • Faster sorting with Go generics - Eli Bendersky's website

                                              Recently, a new set of sorting functions has landed in Go's golang.org/x/exp/slices package [1]. These functions leverage Go generics to provide a more ergonomic API for sorting (without requiring users to implement sort.Interface), and also deliver a nice performance improvement, as the CL demonstrates. In this post, I'll dive deep into why these generic functions are faster than the existing one

                                              • Redirect

                                                Click here to be redirected.

                                                  Redirect
                                                • 見て理解するジェネリクス 基礎から共変・反変までバッチリ習得

                                                  Java を題材に、ジェネリクスについて「あー、理解したっぽい」を目指します。 使用言語は Java ですが、この Book は特定の言語の文法書ではありません。ジェネリクスの概念そのものの理解を目指します。 ジェネリクスについて曖昧な人も、ジェネリクスについて今必要ないと思っている人にも読んでもらいたいと思い書きました。 40 枚以上の図を見ながら、目次の順にステップアップで理解していきましょう。

                                                    見て理解するジェネリクス 基礎から共変・反変までバッチリ習得
                                                  • Go 1.18集中連載 ジェネリクス | フューチャー技術ブログ

                                                    ジェネリクスGo 1.18で入る機能で注目度が高い新機能がジェネリクスです。Goに対する批判的な言葉としてよく使われるものが「ジェネリクスがない」というものでした。Goを長く使っている人は「ジェネリクスなんていらん」と言い続けてきたし、個人的にもいまだになくてもいいと思っているのですが、大きな変更であるし、これから影響もいろいろある領域ですので学ぶ必要はあるでしょう。自分で書かなくても、書かれたコードを読むこともあるでしょうし。 ジェネリクスのチュートリアルが追加されています。 https://go.dev/doc/tutorial/generics mattnさんの動画もあります。 文法的には基底型を表すチルダ演算子が増えたりいろいろ変更が入っています。 とはいえ、constraintsパッケージが1.18に入る予定だったのが、一旦準標準パッケージに格下げされたり、まだまだいろいろ変更が

                                                      Go 1.18集中連載 ジェネリクス | フューチャー技術ブログ
                                                    • Go の "Type Sets" proposal を読む

                                                      Intro 読者の想定知識 この記事で出てくるGo言語仕様用語 サマリー Context Type Parameters Proposalの要点 Type listの必要性 暗黙的な"underlying type matching"の問題 type listからsum typeへ underlying type matchingと代入可能性 underlying type matchingと型switchステイトメント underlying type matchingの表現力の限界 Type Sets Proposal Type sets(型集合) 型Tがinterface ITを実装するための条件 要素を埋め込んだインタフェースのtype set interface elements(インタフェース要素) 任意の型(インタフェース型に限らない) approximation elemen

                                                        Go の "Type Sets" proposal を読む
                                                      • When To Use Generics - The Go Programming Language

                                                        The Go 1.18 release adds a major new language feature: support for generic programming. In this article I’m not going to describe what generics are nor how to use them. This article is about when to use generics in Go code, and when not to use them. To be clear, I’ll provide general guidelines, not hard and fast rules. Use your own judgement. But if you aren’t sure, I recommend using the guideline

                                                          When To Use Generics - The Go Programming Language
                                                        • Go Genericsを使ってgo-optionalを書いた / Go Generics感想 - その手の平は尻もつかめるさ

                                                          Go Genericsがどんなもんか試してみたかったので、これを使ってOptionの実装を書いてみました。 github.com 基本的な使い方としてはSynopsisを読んでもらえばわかると思いますが、ユーティリティとしては IsSome() IsNone() Take() TakeOr() TakeOrElse() Filter() Map() MapOr() Zip() ZipWith() Unzip() UnzipWith() あたりを取り揃えております。examplesも併せてご覧いただくとおおよその使い方の雰囲気が掴めると思います。 利用のためにはまだunstableな最新版 (go1.18) を使う必要があるので、gotipとかを使って新しい処理系を引っぱってくる必要があります。 で、GoのGenericsを使ってみた感想としてdefault valueとかconstrain

                                                            Go Genericsを使ってgo-optionalを書いた / Go Generics感想 - その手の平は尻もつかめるさ
                                                          • Redirect

                                                            Click here to be redirected.

                                                              Redirect
                                                            • Go 1.18 でやってくる Generics とは

                                                              Go 1.18 でやってくる Generics とは Generics で Go はどの様に変わるのか DevFest Tokyo 2021

                                                              • ジェネリクスのメリットって、何?

                                                                こんにちは。株式会社プラハCEOの松原です。 だいぶ前ですが、弊社に入社したメンバーから「ジェネリクスのメリットがいまいちピンとこない」と聞かれたので思ったことをまとめてみます ジェネリクスの使い方 ひとまずTypeScriptでジェネリクスの使い方をおさらいしてみます function hoge1(input1: string) { console.log(input1) return input1 } function hoge2(input2: number) { console.log(input2) return input2 } hoge1("string only") hoge2(100000)

                                                                  ジェネリクスのメリットって、何?
                                                                • Go言語のジェネリクス入門(2) インスタンス化と型推論

                                                                  はじめに 注意: 2023/06/08更新 Go1.21(順調なら2023年8月にリリース予定)において、型推論アルゴリズムの枠組みが新しくなります。 この記事の多くの内容は古いものとなります。 更新予定は今のところないので、注意書きを記載しておきます。 ↑の変更のポイントだけ筆者なりにまとめておくと、関数引数型推論と制約型推論との間の順序の関係がなくなることと、順序の関係がなくなることによって型推論に使える情報の種類を増やしやすくなることがポイントです。 注意 この記事はGo1.18リリース前に書いたのですが、そのせいでGo1.18以降で動作しなくなっているサンプルコードがあります。 具体的には、Go1.18リリース時点では「パラメータ化された型」にたいする型推論が行われなくなりました。そのため、このような型推論についてのサンプルコードが動作しなくなっています。 型推論アルゴリズム自体は

                                                                    Go言語のジェネリクス入門(2) インスタンス化と型推論
                                                                  • Go1.18のGenericsで出来ないこと

                                                                    はじめに 先日Go1.18がリリースされました. リリースノートを見るとGo1.18の時点でのlimitationsが書いてあるのでコード書いて確認します. 全部で6つあります. 1つ目 The Go compiler cannot handle type declarations inside generic functions or methods. We hope to provide support for this feature in Go 1.19. genericな関数やメソッドの中で型宣言できない. package main import "fmt" func main() { fmt.Println("Hello, 世界") } func GenericsF[T any]() { // [NG] type declarations inside generic func

                                                                      Go1.18のGenericsで出来ないこと
                                                                    • 【PHP next】PHPにおけるジェネリクスの現状 - Qiita

                                                                      Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

                                                                        【PHP next】PHPにおけるジェネリクスの現状 - Qiita
                                                                      • Shaving 40% Off Google’s B-Tree Implementation with Go Generics

                                                                        There are many reasons to be excited about generics in Go. In this blog post I’m going to show how, using the generics, we got a 40% performance gain in an already well optimized package, the Google B-Tree implementation. A B-Tree is a kind of self-balancing tree. For the purpose of this blog post it’s sufficient to say that it is a collection. You can add, remove, get or iterate over its elements

                                                                          Shaving 40% Off Google’s B-Tree Implementation with Go Generics
                                                                        • 手を動かして学ぶ Go1.18の新機能

                                                                          このブラウザ バージョンのサポートは終了しました。サポートされているブラウザにアップグレードしてください。

                                                                            手を動かして学ぶ Go1.18の新機能
                                                                          • GitHub - mattn/go-generics-example: Example code for Go generics

                                                                            You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                                              GitHub - mattn/go-generics-example: Example code for Go generics
                                                                            • Zig-style generics are not well-suited for most languages

                                                                              Zig-style generics are not well-suited for most languages Too long; didn’t read: Zig’s compilation scheme for generics shares a lot of similarities with C++, and hence the pitfalls too. Such a compilation scheme is not well-suited to all languages, so armchair suggestions about how other languages should embrace Zig-style generics are misguided. Ain’t nobody handing out free lunches in Generics La

                                                                              • All your comparable types - The Go Programming Language

                                                                                On February 1 we released our latest Go version, 1.20, which included a few language changes. Here we’ll discuss one of those changes: the predeclared comparable type constraint is now satisfied by all comparable types. Surprisingly, before Go 1.20, some comparable types did not satisfy comparable! If you’re confused, you’ve come to the right place. Consider the valid map declaration var lookupTab

                                                                                  All your comparable types - The Go Programming Language
                                                                                • Type Sets Proposalを読む(2)

                                                                                  はじめに Type Sets Proposalとは何か interface/constraintに対して制限を追加する EBNFによる表現 なぜこのように制限するのか 具体例 unionsを標準形に変形する 標準形のunionsを1つにまとめる メソッドのインライン化 最終形 ある型が型制約を満たすかどうかの判定 ある型制約が別な型制約に含まれるかどうかの判定 この制限がないとどうなるか 最後に はじめに この記事は、https://github.com/golang/go/issues/45346 に加えられた修正内容とその意味について説明するもので、Goの"Type Sets" Proposalを読むの続編です。前編を読んでいない方は先に読んでからこの記事を読んだ方がわかりやすいと思います。 前提となる知識は次のようなものです。 Go言語についての初歩的な知識と実装経験(A Tour

                                                                                    Type Sets Proposalを読む(2)
                                                                                  1

                                                                                  新着記事