Hello world. I have a proc, called todouble. I want that: When I call it like this: todouble mynumber or todouble(mynumber), it behaves like: func todouble(num: SomeNumber) = num * 2. When I call it like this: mynumber.todouble, it behaves like: proc todouble(num: var SomeNumber) = num *= 2.
Is it possible ? How ?
form what i know and i am uber newb,
calling proc something.call() is same as call( something ) , i dont think you can do that whiteout some marcro magic or something similar, ofc its possible i am wrong :)
Maybe by changing the case:
func toDouble(num: SomeNumber) = x * 2
proc ToDouble(num: var SomeNumber) x *= 2
I hadn't hard about that
You may consider reading some of the tutorials maybe?
dup() macro was explained in my book with example in section
Procedure Parameters of Var Type
I like the irony in using the dup macro to prevent duplicate code.
He could save others from duplication, but not himself.