-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the supports to use Funcref and Data.Closure's {callable} in Data.List #511
Conversation
aiya000
commented
May 18, 2017
- Data.List will support Funcref
- {callable} is not supported in here
- Data.List.Closure will support {callable}
- Data.List.Closure provides to call Data.List's functions
Modify document of .foldl1() Modify test of .foldl1()
Upgrade the implementation of .foldr() Modify test of .foldr() Add document of .foldr()
Add document of .foldr1() Modify test of .foldr1()
Add funcref support Add Data.Closure support
Add funcref support Add Data.Closure support Add Notice to document Add test
\ : execute(printf("throw 'vital: Data.List: sort_by() cannot compare %s and %s'", string(x), string(y)), 1) | ||
endfunction | ||
|
||
return s:sort(a:list, function(scope.compare_with, [], scope)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[vimlint] reported by reviewdog 🐶
E118: Too many arguments for function: function
" Lifts the string expression to the function. | ||
" s:sort_expr must be defined as the string expression of the binary function | ||
" before this is called. | ||
function! s:_compare_by_string_expr(a, b) abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:a
" Lifts the string expression to the function. | ||
" s:sort_expr must be defined as the string expression of the binary function | ||
" before this is called. | ||
function! s:_compare_by_string_expr(a, b) abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:b
" s:sort_expr must be defined as the string expression of the binary function | ||
" before this is called. | ||
" a:a and a:b are used in s:sort_expr . | ||
function! s:_compare_by_string_expr(a, b) abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:b
" s:sort_expr must be defined as the string expression of the binary function | ||
" before this is called. | ||
" a:a and a:b are used in s:sort_expr . | ||
function! s:_compare_by_string_expr(a, b) abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:a
|
||
" Notice: | ||
" This is not job safe. | ||
" The function may not work correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data.Closure なら binding で変数渡せそう?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここの目的は{closure}をFuncrefに変換することなので、{binding}使うとData.Listの各関数に{closure}渡すことになってしまうような?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
はい、closure 的なことがやりたければ、Vim 7.4 だったら Data.Closure オブジェクトみたいな dictionary を持ちまわるしかないと思います
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
それだとData.Listの関数がClosure対応をしてないのでだめな気がする……。(Data.Closure遅かったので、削除して回ってる)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ、なるほど、そういう方針でしたか…
辞書の寿命が切れる…… > wip |
|
この PR の概要間が空いてしまったので一旦自分のためにも整理します (ほぼ PR 本文と同じですが日本語&思い出す意味でも…)
後で修正したい点 (既存実装の問題、Vim 7.4 サポート終了、...)既存実装とかの事まで言ってたらキリがないので、とりあえずこの PR では request changes はしないでおきますが、備忘録として。 8.1 が出て 7.4 サポートは打ち切る事になった (#580) ので今だと
とかあるのでもうちょっと短く書ける部分もありそうです。 上記以外で、その他にも色々と直したい部分 (既存の Data.List の問題)
|
@@ -3,6 +3,15 @@ | |||
let s:save_cpo = &cpo | |||
set cpo&vim | |||
|
|||
function! s:_vital_loaded(V) abort | |||
let s:Closure = a:V.import('Data.Closure') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使ってなさそう
Data.List が Data.Closure に依存しちゃってるの直したらマージしちゃって良さそう (と個人的には思いますがどうでしょう >ALL) |
I agree with tyru. Let's remove Data.Closure dependency from Data.List and merge this pullreq. |
優勝感 |
優勝を完了しました(多分)! @tyru まとめてくださって助かりました、ありがとうございます! |
LGTM |
@aiya000 ありがとうございました! |
これせっかくなので周知されてこそ意義あると思うし、作者直々の使い方解説ブログ記事とかがあると、すごい便利そうです! |
期待 |
感極まってきまし (た) |
よっ(しゃ) |
というわけで TODO
|
@Milly Data.Listのpop(), push(), shift(), unshift(), clear()などは意図的に破壊的です。 うーんこれどうしようかな
書いててあれだけど、個人的にvitalではA, Bは良くないと思います。細かく分かれすぎると結局ユーザにとって分かりにくいかなと。Dにする場合、どういうのがいいかなあ. 思いつかなければCが自動優勝 |
Cよさそう! |
とりあえずドキュメントに書くのは必須ですね。 |
とりあえずのCのためのpullreq作っておきます #592 (comment) |