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
One of the most pleasured feature from D. I really interesting can it be implemented in V?
This syntax gives you really nice expirience when you write in functional style. This syntax also can allow to remove this form of methods declaration fn (a Type) foo_bar(s string) string and write simply fn foo_bar(a Type, s string), so all the way how functions should be declared start being more consistent
Use Case
D examples
// UFCS style
10.iota
.filter!(a => a % 2 == 0)
.writeln();
// Traditional style:
writeln(filter!(a => a % 2 == 0)
(iota(10)));
i'm personally very much against the idea of replacing methods with functions, they allow the type's methods to be with the type which is much more organised and intuitive, whereas having all methods be functions would lead modules to be much more cluttered and making it almost impossible to differentiate traditional methods and functions apart
Im really cant imagine situation where i need to differ methods and functions. In this case we can easily extend other code without any breakings because we cant touch private things in that functions, and it even allows to extend regular types like int or string.
It is like mixins
Pipe operator is ok, but it will add new pipe operator, UFCS just reuse .. Also UFCS has clearest syntax even in simple situations. I mean you write subject.op(arg), but in other case you woud write op(subject, arg) or subject |> op(arg), for me first way is the clearest one
Describe the feature
One of the most pleasured feature from D. I really interesting can it be implemented in V?
This syntax gives you really nice expirience when you write in functional style. This syntax also can allow to remove this form of methods declaration
fn (a Type) foo_bar(s string) string
and write simplyfn foo_bar(a Type, s string)
, so all the way how functions should be declared start being more consistentUse Case
D examples
Proposed Solution
I like how it works in D
https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs
Other Information
It can be done even without BC (need to discus)
Acknowledgements
Version used
0.4.5
Environment details (OS name and version, etc.)
linux, Ubuntu 22.04.2 LTS
macos, Sonoma 14.4.1
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: