Re: Function as object? Object as function?

2018-04-08 Thread mjendrusch
This has to be recent then, both the above snippets do not produce that deprecation warning on Nim 0.18.0 at play.nim-lang.org in the presence of pragma experimental, while producing exactly that warning without experimental. I'll check it again on devel when I get back to my machine. It seems

Re: Function as object? Object as function?

2018-04-08 Thread Udiknedormin
I do use {.experimental.}. The communicate is precisely: "Warning: overloaded '.' and '()' operators are now .experimental; () is deprecated [Deprecated]"

Re: Function as object? Object as function?

2018-04-08 Thread mjendrusch
Did you add the {.experimental.} pragma? That should remove the deprecation warning, as that warning happens because () is experimental.

Re: Function as object? Object as function?

2018-04-08 Thread Udiknedormin
Cool! I didn't see it coming, () operator. Last time I asked about it, there was no proposal of it yet, if my memory serves me well.

Re: Function as object? Object as function?

2018-04-08 Thread mjendrusch
: int): int = c.val * i # Make the thing exponentiable. proc `^`(c: Callable; i: int): int = c.val ^ i let c = Callable(val: 1) echo c ^ 2 == 1.c ^ 2 # true! You could probably object-ify any given function to behave this way using a macro.

Function as object? Object as function?

2018-04-08 Thread Udiknedormin
I would like to have a function behaving like an object, so I could overload an operator on that function. I need the following to be true: assert 1.fun ^ 2 == fun ^ 2 I know I could use fun() with a default argument but that's that syntax isn't acceptable in this context