Re: Lexers and parsers in nim
> For educational project, parse it by hand For educational **and serious** project, parse it by hand (Nim parser is handwritten, as is GCC, Clang, MSVC, FPC, OpenJDK, Golang and many others). Use tools only for quick and dirty one 😉
Re: Fatal compilation error on Windows
> I'm using GCC on linux too, so that can't be the problem, unless there is > some Windows specific quirk. Yes, command line on windows is limited to 8191 characters. On Linux it is variable but generally much larger, you can check yours using: $ getconf ARG_MAX it is 2097152 on my machine.
Re: Array indexed by a subrange type
> I guess this is because the array declaration expects a type whereas my const > AllPoints is a slice, but I don't fully understand the details. Correct, when you use type you define a subrange, but with const it's a slice. As you can read in the docs, array declaration expects an ordinal type for its index, which subrange fulfills but slice doesn't. OTOH, for .. in can loop over a slice, but not a subrange. Using x.low .. x.high you created a slice, so for .. in works with it.
Re: procs where you forget to return a value
I agree that a simple code like this: proc p: int = echo "test" var x = p() echo x should issue a warning (like in Pascal). Error is fine, too (like in Java), since it's very seldom an intention to do so.
Re: Introducing Reel Valley
> I'm proud to announce that another game written in 99.99% pure Nim is online > now. You can play it on Facebook. Mobile version is coming later on. Comments > are welcome! =) I hate you, IT'S TOO ADDICTIVE!!! :v :v :v
Re: Nim to C transpiler
> How reliably can Nim translate to C or C++? As with any other compilers: nothing but [a bunch of test cases](https://github.com/nim-lang/Nim/tree/v0.17.0/tests), which is why code generation bug can still exist because covering all cases is almost impossible. Compiler's basic building block is a node in its hierarchical syntax tree, which maps to one or several (hopefully not too many) instructions in the _target architecture_ (in which it's possible to create one based on any other language including C and C++). By ensuring these nodes produce correct instruction sequence, the whole tree can be assumed to be as correct, but of course it's not easy to prove and corner cases do exist, along with optimizations that can modify the tree wrong.
Re: "Warning: Cannot prove that 'result' is initialized"
The warning comes from parseEnum implementation, just propagated to your code (if the return value cannot be proven to have been initialized, then so does the variable holding it). Simply ignore for now, when the compiler changes this behavior to compile time error, the implementation should have also been fixed. From parseEnum code, return value is always initialized or an exception shall be raised (probably the compiler cannot yet incorporate exception into the proving algorithm).
Re: Aporia IDE unable to compile
> Well, it seems to be easy guessing the problem: He posted "E:New > folderbinnim.exe" and ""E:New'. OS er..." so the problem may be the space in > the path name for the nim.exe More like a backslash vs slash problem for me. Backslash is often used as escape character and needs to be written twice to work or simply replace with slash (Windows will happily accept both as path separator).
Re: App compiling option
take a look at \--app option
Re: Is Nim better than C?
> but still, I have the interface to all software that are written in C. As in other languages, you can write Nim bindings for them. Be it manually by hand or using c2nim.
Re: Is Nim better than C?
Nim can do everything that C can do (it is designed as a system programming language, can and has been proven to program a kernel), but will warn you about safety more than any C compiler will ever do. Nim has much more advanced features, so you can do things that are either inelegant, hard or impossible in C. In short, yes it's better and superior than C, as many other languages already do.
Re: Nim running Lua calling Nim
Just as how it's done from any other languages: import lua proc nimluafunc(L: PState): cint {.cdecl.} = let i = tonumber(L,1) let j = tonumber(L,2) let k = i + j pushnumber(L,k) result = 1 let l = newstate() openlibs(L) register(L, "callablefromlua", nimluafunc) discard dostring(L,""" x = callablefromlua(3,7) print(x) """)