Re: Dead Code elimination

2019-08-15 Thread jyapayne
See this forum post: [https://forum.nim-lang.org/t/1209](https://forum.nim-lang.org/t/1209)

Re: Dead Code elimination

2019-08-15 Thread Araq
> I am writing an application that will have objects that I write in my modules > that will not have any objects created at compile time. I do not want any of > these eliminated. They will be created at runtime when a configuration file > is read into the app. Well either there is a path to

Re: Dead Code elimination

2019-08-15 Thread cdome
IMO, I will not encounter any problems. AFAIK, no extra protection needed.

Dead Code elimination

2019-08-15 Thread jlhouchin
Hello, I have searched the Nim site and this forum trying to read up on deadCodeElim. I am not finding sufficient information for me to understand. Pointers to docs are always welcome. Looking through the manual and compiler or internal guides, I did not find much or overlooked something. I

Re: [RFC] Project Picasso - A multithreading runtime for Nim

2019-08-15 Thread GordonBGood
@Araq, @mratsim: As promised, I'm posting some code that shows the current difficulty of bypassing the overly simplistic (and performance costly) default behaviour for the current channels and threadpool libraries of deepCopy'ing all GC'ed ref's so they won't be prematurely destroyed if they go

Re: Compile C file together with Nim one

2019-08-15 Thread cblake
Yet another approach is to have the `nim c`-generated C code just `#include "foo.c"` via `{.importc: "func", header: "foo.c".}`.

Re: Are NimNodes ref types or functionally equivalent to ref types?

2019-08-15 Thread mratsim
system.`=`(a, b) Run should work NimNode are ref types with an overloaded = proc.

Re: What do you think about the programming language NIM?

2019-08-15 Thread cblake
I do not agree that lazy linear lists are the "main example" of recursion. They may be the _simplest_ example, thusly allow several easy workarounds. I mentioned "trees" right in my comment. Most of the (admittedly subjective) elegance of tree algorithms comes from the way recursive code

How to read binary file in Nim?

2019-08-15 Thread nnahito
I want to read binary file inNim-language. Because I want to work with WAV files. But I don't know how easy it is to read the first four bytes. This may be because I am not good at English. I wrote the following code. However, nil is displayed. var hFile = open("example.wav",

Re: How to read binary file in Nim?

2019-08-15 Thread mratsim
Your buffer points to nothing, allocate an `array[4, byte]` and pass its address to readBuffer. I suggest you use streams if you need to save your position/restart your processing. For example this is [how I read the first 6

Re: How to read binary file in Nim?

2019-08-15 Thread treeform
Here is my code that reads wave files: [https://github.com/treeform/euphony/blob/master/src/euphony/wav.nim](https://github.com/treeform/euphony/blob/master/src/euphony/wav.nim) There i use newFileStream which makes reading binary files really easy. Just use readStr, readUint16, readUint32...

Re: Are NimNodes ref types or functionally equivalent to ref types?

2019-08-15 Thread solo989
It does. I'm surprised I didn't try that before. Thanks. I assumed based on how NimNodes were implemented that the == operator was completely overwritten.

Re: Dead Code elimination

2019-08-15 Thread juancarlospaco
You dont need extra protections. Look at this video, mainly the part about how the AST works: [https://www.youtube.com/watch?v=QXjU9qTsYCc](https://www.youtube.com/watch?v=QXjU9qTsYCc)

Re: What do you think about the programming language NIM?

2019-08-15 Thread cblake
There are always workarounds since CPUs are little state machines. That should be news to no one. Recursion working makes code look much nicer, IMO. For what it's worth, the example considered among the more compelling by the Python guys back in the Python 2.3 days when they added generators

Re: What do you think about the programming language NIM?

2019-08-15 Thread jyelon
I'm surprised everyone is treating owned and unowned refs as if they were something new. C++ has owned and unowned refs. In C++, they're called "std::unique_ptr" and "dumb pointers." The semantics of the C++ version are almost exactly the same as the semantics of the nim version - the one