Re: Alias for proc names -- any progress?

2019-07-25 Thread timothee
> 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

Re: Alias for proc names -- any progress?

2019-07-25 Thread Stefan_Salewski
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

Re: Alias for proc names -- any progress?

2019-07-25 Thread sschwarzer
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.

Re: Alias for proc names -- any progress?

2019-07-24 Thread Stefan_Salewski
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.

Re: Alias for proc names -- any progress?

2019-07-24 Thread timothee
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 #

Re: Alias for proc names -- any progress?

2019-07-15 Thread roel
Wouldn't an additional proc suffice? proc length[T](t: T): int {.inline.} = getLength(t) Run

Re: Alias for proc names -- any progress?

2019-07-15 Thread Stefan_Salewski
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:

Re: Alias for proc names -- any progress?

2019-07-15 Thread Stefan_Salewski
Yes, you could do that, and you can do that -- if there is only one existing proc with that name. See my initial post.

Re: Alias for proc names -- any progress?

2019-07-15 Thread mratsim
AFAIK in previous nim versions you could just do `const length = getLength`

Re: Alias for proc names -- any progress?

2019-07-15 Thread Stefan_Salewski
Oh, that is interesting. Maybe you should tell Araq about that solution :-)

Re: Alias for proc names -- any progress?

2019-07-15 Thread leorize
Here you go: [https://play.nim-lang.org/#ix=1OyF](https://play.nim-lang.org/#ix=1OyF)

Re: Alias for proc names -- any progress?

2019-07-15 Thread Araq
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.

Re: Alias for proc names -- any progress?

2019-07-15 Thread Ward
In wNim, I wrote a simple "[property](https://github.com/khchen/wNim/blob/master/wNim/private/wMacro.nim)" macro to solve the problem.

Alias for proc names -- any progress?

2019-07-15 Thread Stefan_Salewski
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