Re: Begginer's question - pointers and refs

2019-03-21 Thread aguspiza2
Yes you are right. I was thinking about type definiton while the question was about variable definition. Thanks.

Re: Begginer's question - pointers and refs

2019-03-21 Thread mratsim
@aguspiza, I think you are confused about mutability/immutability, var and ref. var means mutable. ref means object on the heap with reference semantics. They are somewhat orthogonal concepts.

Re: Begginer's question - pointers and refs

2019-03-20 Thread aguspiza2
Use var sdl_rect : Rect If you ate going to process a lot of them sequentially. Use var sdl_rect : ref Rect If you only handle those instances individually or if you use OOP or if there is a lot of fields (data) in the object

Re: Begginer's question - pointers and refs

2019-03-20 Thread mratsim
In the example it's not a pointer though, it's a stack object (assuming Rect is a simple object).

Re: Begginer's question - pointers and refs

2019-03-19 Thread moerm
I disagree, at least regarding the question in the title. A ref is always preferable unless one _needs_ a pointer. And the heap vs. stack is not Nim specific.

Re: Begginer's question - pointers and refs

2019-03-19 Thread Araq
`var sdl_rect : Rect` is better.

Re: Begginer's question - pointers and refs

2019-03-19 Thread Stefan_Salewski
That is not an easy topic for a beginner, you may start with [https://peterme.net/nim-types-originally-a-reddit-reply.html](https://peterme.net/nim-types-originally-a-reddit-reply.html)

Begginer's question - pointers and refs

2019-03-19 Thread Tomek
I'm still new to Nim (got it a couple of days ago). Both versions work. Which one is better? (It is not clear, or I have missed something in docs.) The first: var sdl_rect : Rect sdl_rect = ( (cint)0, (cint)0, (cint)10, (cint)10 ) # usage: (addr sdl_rect), when ptr Rect is