Re: Return values question

2016-12-12 Thread def_pri_pub
Thanks for that post, it definitely gave me a lot of insight into what is going on in Nim. I'm working with a lot of pixel data and wanted to return it from a function as a seq[uint8]. I want to avoid it doing an necessary copy (on return) for a lot of data (which I assume is happening right now

Re: Return values question

2016-12-12 Thread Varriount
> I guess that one could put the return value as the first one on the stack > frame, so there is no copy involved. It seems to me that this is safe to do > when one uses the special variable result. It depends on the calling > convention, but I think it should be doable? This is close to how mo

Re: Newyear is coming , is 2017 the year for nim?

2016-12-12 Thread Krux02
If there is a poof and Nim is Java, then I am out. Java is horrible.

Re: Return values question

2016-12-12 Thread andrea
> Technically, values are always copied when returned from a procedure - > there's not really any other way.* If values were to be always passed by > pointer/reference, how would values that are stored on the function call > stack persist after the procedure has returned? I guess that one could

Re: Return values question

2016-12-12 Thread Arrrrrrrrr
Good post. Def would say "look at the generated code". This is what i got: proc fillWith(n, count: int): seq[int] = var s: seq[int] = @[] for i in countup(0, count - 1): s.add(n) return s proc main = let counter = fillWith(7, 3) e

Re: Hey , nim compile --run helloworld.nim

2016-12-12 Thread chrisheller
Yes, the --run (or -r) will run after compiling helloworld.nim. nim --run helloworld.nim won't just run your script.

Re: ARM compiler 6

2016-12-12 Thread chrisheller
Yes, there are several posts about how to set things up for using Nim with ARM (either on the device or cross-compiling). Search the forum for ARM and take a look at some of those posts.

Re: Return values question

2016-12-12 Thread Varriount
**TL;DR**: Strings and sequences, like objects and integers, are copy on _assignment_. References are not. Technically, values are always copied when returned from a procedure - there's not really any other way.* If values were to be always passed by pointer/reference, how would values that are

Return values question

2016-12-12 Thread def_pri_pub
How does Nim return values from a proc? Are basic datatypes (like int and float) returned by copy? What about more complex structures like sequences and strings? For example, would this proc: proc fillWith(n, count: int): seq[int] = var s: seq[int] = @[] for i in count