www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - d > rust

reply monkyyy <crazymonkyyy gmail.com> writes:
I brought up this code block in a meta-programming discord

```d
template staticCurry(alias F,Args...){
template staticCurry(S...){
     auto staticCurry(T...)(T t)=>F!(Args,S)(t);
}}
```

apparently its very very hard in c++ and impossible for rust to 
replicate; feel free to use it in any future arguments
Jun 23
next sibling parent Kapendev <alexandroskapretsos gmail.com> writes:
On Wednesday, 24 June 2026 at 02:36:12 UTC, monkyyy wrote:
 I brought up this code block in a meta-programming discord

 ```d
 template staticCurry(alias F,Args...){
 template staticCurry(S...){
     auto staticCurry(T...)(T t)=>F!(Args,S)(t);
 }}
 ```

 apparently its very very hard in c++ and impossible for rust to 
 replicate; feel free to use it in any future arguments
Thank you. Don't forget the Zig people!
Jun 23
prev sibling parent reply Serg Gini <kornburn yandex.ru> writes:
On Wednesday, 24 June 2026 at 02:36:12 UTC, monkyyy wrote:
 apparently its very very hard in c++ and impossible for rust to 
 replicate; feel free to use it in any future arguments
GPT suggested for C++: ```cpp template <template<class...> class F, class... Args> struct static_curry { template<class... S> struct apply { template<class T> auto operator()(T&& t) { return F<Args..., S...>{}(std::forward<T>(t)); } }; }; ``` For Nim: ```nim template staticCurry(F: untyped, args: varargs[untyped]): untyped = template inner(s: varargs[untyped]): untyped = proc call[T](t: T) = F(args, s, t) ``` For Haskell: ```haskell type StaticCurry f args s = f args s ``` For Zig: ```zig fn staticCurry(comptime F: anytype, comptime Args: anytype) type { return struct { pub fn apply(comptime S: anytype, t: anytype) void { F(Args, S, t); } }; } ``` Don't know if any from above will work :)
Jun 23
parent matheus <matheus gmail.com> writes:
On Wednesday, 24 June 2026 at 06:41:54 UTC, Serg Gini wrote:
 ...
 GPT suggested

 for C++:
 ...
It might work but it's ugly hmm... =] Matheus.
Jun 24