> Will you alias work for the result variable too? Would be great -- I had
> often procs like
it works, I just added a test case for that see
Will you alias work for the result variable too? Would be great -- I had often
procs like
[https://github.com/StefanSalewski/cdt/blob/master/src/cdt/dt.nim#L92](https://github.com/StefanSalewski/cdt/blob/master/src/cdt/dt.nim#L92)
where the symbol result is used really often. And the
As I understand it, this is still a pull request that hasn't been merged.
I think having aliases would be great, but I also see the potential conflict
with already defined operators that is mentioned in the comments of the PR.
Great, thanks!
I do not need aliases often, but for a few rare cases I really missed it.
For procs const was not really working perfect in the past, and I was never
fully happy using templates to just alias a var.
properly fixed here:
[https://github.com/nim-lang/Nim/pull/11822](https://github.com/nim-lang/Nim/pull/11822)
nim has a real alias that works with any symbol #11822
proc getLength(i: int): int = sizeof(i)
proc getLength(s: string): int = s.len
# const length = getLength #
Wouldn't an additional proc suffice?
proc length[T](t: T): int {.inline.} = getLength(t)
Run
I have just added that to my code generator, but the funny fact is that this
will not work when there is only one proc with that name:
#proc getLength(i: int): int =
# sizeof(i)
proc getLength(s: string): int =
s.len
const
length = (proc(s:
Yes, you could do that, and you can do that -- if there is only one existing
proc with that name. See my initial post.
AFAIK in previous nim versions you could just do `const length = getLength`
Oh, that is interesting. Maybe you should tell Araq about that solution :-)
Here you go:
[https://play.nim-lang.org/#ix=1OyF](https://play.nim-lang.org/#ix=1OyF)
There still is no different solution. IMO proc aliases are a bad idea and you
shouldn't offer them. People can always write `module.foo` anyway.
In wNim, I wrote a simple
"[property](https://github.com/khchen/wNim/blob/master/wNim/private/wMacro.nim)"
macro to solve the problem.
I just tried to optimize the gintro generated code a bit.
One known issue is the alias for proc names -- some people like the get and set
prefixes for getters and setters, others don't. Like in container.getChild() vs
container.child().
Some years ago I tried to use plain const proc names as
14 matches
Mail list logo