Concat for linked lists?

2020-12-14 Thread Araq
PRs are welcome. Few people use lists.nim as it's almost always slower than a seq.

Concat for linked lists?

2020-12-14 Thread salvipeter
Hi, I couldn't find an O(1) operation that concatenates two lists. Something like this: proc concat[T](a: var SinglyLinkedList[T], b: SinglyLinkedList[T]) = ## Concatenates (adds to the end) `b` to `a`. Efficiency: O(1). ## Note that the two lists share structure after

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread jrfondren
> Let's see... Your quote includes a link, you know? ctrl-f cast: 0 hits ctrl-f crypt: 5 hits. Used twice: if hash == crypt(pass, matches[0]): if hash == crypt(pass, salt) Run It's used directly, without `cast`. It's still not good enough to be part of a Ni

C++ Smart pointers 101 and FFI

2020-12-14 Thread mantielero
Thanks Treeform. I bet I will need it!

Nim for mobile

2020-12-14 Thread treeform
Also see: * my project * manual android * manual iOS

C++ Smart pointers 101 and FFI

2020-12-14 Thread treeform
I don't think you can avoid them if they are used internally in the library. You would have to wrap them and it might get ugly: This C++ : osg::ref_ptr root = new osg::Group; Run Will probably turn into this Nim: var root: refPtr[Group] = newGroup()

Nim for mobile

2020-12-14 Thread mrhdias
Check this project:

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread Araq
> But it is a good friction pushing coders to add idiomatic and safe API on top > of an imported C-library. We already have this good friction, `cint` and `ptr UncheckedArray` are not all that pleasant to look at or to work with. Neither is having to `discard` arbitrary return values (returned

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread slonik_az
As @snej already mentioned, Rust's `unsafe` provides a contract-based separation of responsibilities between a programmer (inside `unsafe` blocks) and the compiler (outside of `unsafe` blocks). A Rust programmer can also tag any function with `unsafe` to make it tainted even if compiler does not

C++ Smart pointers 101 and FFI

2020-12-14 Thread mantielero
I am facing smart pointers or something like that in some big libraries. I understand that this is how C++ deal with the lack of GC, is it like that? How should I deal with them when facing a library that use them? Should I try to use them through Nim, or should I try to avoid them and use Nim's

Advent of Nim 2020 megathread

2020-12-14 Thread fxn
Oh yes. It was a cool mind trick, we are talking masks, 0s, 1s, ..., so that made me think about binary numbers without paying attention to the explanation. It was only after failing to generate the correct output that I read the problem statement again looking for something I missed.

Newbie: Small program fails in "-d:release" but works with plain build

2020-12-14 Thread protium
Thanks for your feedback, everyone. This one is proving very vexing. I added additional defensive coding to check the row counts before proceeding. It doesn't make a difference. If I try @jrfondren 's suggestion to run compile with `nim -d:release --stackTrace:on --lineTrace:on c src/BuildEcDat

Advent of Nim 2020 megathread

2020-12-14 Thread al1ranger
I also encountered the same issue. It seems that parseBinInt silently truncates the bit string based on the width of int (the example in the problem had no X in the first four bits and hence 32 bit integers did not cause any problems).

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread Araq
Well I would love to see effort spend on high-quality wrappers myself, however: * c2nim already is too much work for many people, hence nimterop exists which promises to automate it even moreso. * I don't agree we will see more quality code by making the tedious (writing wrapper code) even m

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread snej
> I'm quite sure that every line of the wxWidgets wrapper is "unsafe" \-- > that's the nature of wrapper code, this code doesn't get better when every > 2nd line is a new unsafe: block. I'm not familiar with wxWidgets so I can't speak about that API. But **the point of Rust 's ``unsafe`` is not

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread Araq
> Magical thinking isn't any better than a cargo cult. Well at least it doesn't increase the amount of wrapper code by a factor of 2.

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread snej
> Nim: > > \-- crypt() is useful as-is Let's see... proc crypt(phrase, salt: cstring): cstring {.cdecl, importc, dynlib: "libcrypt.so".} Run It's not useful without a `cast`, wh

Advent of Nim 2020 megathread

2020-12-14 Thread lscrd
Yes and it’s intended. All values in the examples contains only 0 and 1. You have to read carefully the detailed description to see that 11 is decimal 11 and 101 is decimal 101. This is a simple trap but quite effective.

one more "collect" question (bug?)

2020-12-14 Thread HJarausch
Is this a restriction or a bug ? import sugar, strformat var st = collect(newString) : for i in 0..2 : &">> {i}" echo st #[ cannot instantiate: 'newString[typeof: for i in 0 .. 2: var fmtRes_369098797 = newStringOfCap(16) add(fmt

Nim for mobile

2020-12-14 Thread zetashift
There is currently no mature framework for Nim yet with good learning resources. So you'd do a lot of experimenting and probably run up against a lot of stuff depending on what you want to make. The community is active tho so it's not impossible. What is it you like to make?

IS there any beginner friendly tutorial for nim with examples like "Python crash course" etc.?

2020-12-14 Thread zetashift
You could try running through / or @Stefan_Salweski Nim Programming book. And then with that knowledge go through Nim Days: / This should give a beginner a stable foundation and enough projects to build and tinker with.

Advent of Nim 2020 megathread

2020-12-14 Thread fxn
I made the same mistake, memory values are in base 10.

IS there any beginner friendly tutorial for nim with examples like "Python crash course" etc.?

2020-12-14 Thread giga84
thanks Stefan_Salewski. could add some exercises and answers for your book will really be helpful to get a better understanding. Thanks

Advent of Nim 2020 megathread

2020-12-14 Thread bunkford
How come this doesn't work for Day 13 Part 1? import strutils, strscans, tables, sequtils proc solve1(filename: string): int64 = var mask: string var memory = initTable[int, int64]() for line in filename.lines: var mem, num: int

IS there any beginner friendly tutorial for nim with examples like "Python crash course" etc.?

2020-12-14 Thread Stefan_Salewski
At least a start: And of course

IS there any beginner friendly tutorial for nim with examples like "Python crash course" etc.?

2020-12-14 Thread giga84
Hi I am new to programming. I just want to know if there are any beginner friendly tutorial or book for nim programming language like python crash course. With some fun programs you can create at the end like a game, android app etc.. The ones on are not like "p

Best IDE-like Nim experience?

2020-12-14 Thread AmjadBHD
FWIW

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread Araq
> I'm pretty sure that's a bug. Or at least undefined behavior that shouldn't > be buried in the experimental manual It never was my intention to "bury" it -- I think it's overdue we address this hole. The problems that it causes do come up more often with Arc/Orc.

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread saem
With the aforementioned improvements to tagging and possibly type views (haven't dug into then enough) I can see folks being able to leverage the compiler to enforce complex lifetime based architectural assertions. At least one such thing that would benefit game engines (ECS) or anything simila

Nim (1.4 ORC) v.s. Rust in terms of safety?

2020-12-14 Thread mratsim
We already have `{.gcsafe.}`, and `{.noSideEffect.}` blocks and you can tag functions as `{.sideeffect.}`. Why stay at Rust level when you can go full blown Haskell? Example C imported function tagged as side-effect:

Nim for mobile

2020-12-14 Thread archnim
I mean create an app for mobile. With a gui.

Nim for mobile

2020-12-14 Thread mratsim
If you mean compilation on mobile, you can compile Nim for iOS, Android or even the Nintendo Switch and this has been possible for years. If you mean something else (tutorials, tooling, hot-code reloading, ...) can you explain what you want?

Nim for mobile

2020-12-14 Thread qqtop
On Android: install termux from google play pkg install nim now you can compile your nim progs on the phone !

Nim for mobile

2020-12-14 Thread archnim
Hello world. Is it planned for mobile dev to be done in Nim, soon or in a further future ?