Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread alexeypetrushin
> Nim automatically passes by reference when it's faster than passing by copy Are you sure? As one/two years ago that was not the case. And how Nim could do that? As you need to collect and analyse runtime statistics about usage patterns and then decide if passing by value (copying) should be

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread ElegantBeef
It uses a very simple heuristic of anything larger than 24 bytes is passed by reference. Which is simple enough and is generally right.

Advent of Nim 2022

2022-11-30 Thread miran
## Advent of Code 2022 Thursday December 1st at 5 a.m. UTC will mark the start of the eight incarnation of [Advent of Code](https://adventofcode.com/), popular programming contest started back in 2015. The author describes Advent of Code (AoC) as " _a series of small programming puzzles for a

Basic window graphics library?

2022-11-30 Thread PMunch
SDL2 seems like a decent fit

Advent of Nim 2022

2022-11-30 Thread miran
Previous Advent of Nim threads: * [AoC 2018](https://forum.nim-lang.org/t/4416) * [AoC 2019](https://forum.nim-lang.org/t/5588) * [Aoc 2020](https://forum.nim-lang.org/t/7162) * [AoC 2021](https://forum.nim-lang.org/t/8657) * * * Our repositories and solutions: TBA

Advent of Nim 2022

2022-11-30 Thread PMunch
I was thinking of streaming my solutions again this year. Hopefully people will still find that interesting :)

Basic window graphics library?

2022-11-30 Thread jasonfi
Can Fidget handle this? I'm thinking of the keypresses part specifically.

Advent of Nim 2022

2022-11-30 Thread pietroppeter
ye, it's advent of nim time! that time of the year where I am miraculously excited to get out of a bed at 6 am!  I plan to blog about my solutions in nim in my usual repo here: I also plan to share the link to my solutions in reddit daily

Advent of Nim 2022

2022-11-30 Thread hamidrb80
https://github.com/hamidb80/problem-solving/tree/main/advent-of-code/2022

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread ElegantBeef
You still will need to know `lent` vs. `ref` cause they're different constructs, a `ref` is a heap allocated manged pointer whereas `lent` is borrowed memory. Without view types as I said prior `lent` can only be consumed directly as it's not the same. `lent` values can live on the stack, `ref`

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread ElegantBeef
This is not passing though, `lent` is borrowing. Even though the compiler _could_ infer this it's not the same. As without viewtypes any `lent` will copy if it's not directly used due to the implications of a borrow.

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread alexeypetrushin
Hmm, from my point of view "I have some data and I want it to be passed around fast" there's no difference between ref and lent. And if Nim could do it automatically and I don't even had to know about ref and lent that would be ideal situation :)

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread Hlaaftana
I'm guessing "Nim automatically chooses to pass by ref or by copy" doesn't mean "Nim automatically changes between value/reference type semantics".

Upcoming standard library changes

2022-11-30 Thread Araq
The following modules are being moved to Nimble packages: * smtp * asyncftpclient * punycode * The `db_` subsystem. (I hope this list is complete.) No further changes are planned for the time being, it's time to release v2.

Advent of Nim 2022

2022-11-30 Thread MichalMarsalek
I'm doing AoC in Nim again:

Advent of Nim 2022

2022-11-30 Thread bg
I'm in a similar situation as some others: I probably won't have time to do all the days as they come. I plan to share my answers here:

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread alexeypetrushin
My question and objections were to this line: > Nim automatically passes by reference when it's faster than passing by copy, > so no you do not need to always use ref. It seems wile maybe in some cases compiler optimises how data passed around, in other cases it does not. For practical

Upcoming standard library changes

2022-11-30 Thread Hlaaftana
Before starting: I am not part of the Nim team, I'm just following along and want people to have minimal issues the same way I would want for myself. See the original discussion for a more reliable source of information. In light of the new Nim version that has been in development for more than

Advent of Nim 2022

2022-11-30 Thread al1ranger
I will be uploading my solutions here. Most likely I will not be able to complete all the challenges during the event, but I plan to do the unsolved ones afterwards.

Executable crashes unless compiled with -d:release

2022-11-30 Thread Araq
Use `--threads:off` or `--tlsEmulation:off`. I suppose all the BSDs offer working thread local storage implementations these days.

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread Araq
> That would be great. But are you sure Nim can do that? It does that and has always done it. It's simply based on `sizeof(paramType)`.

Do you have to use 'ref' for the field types within ref objects?

2022-11-30 Thread alexeypetrushin
I made a test, where data structure that are declared as reference works x10 faster. import sequtils echo "as value" let prices = (1..100_000).to_seq.map(proc (i: int): float = i.float) proc get_prices: seq[float] = prices for _ in 1..100_000: discard

How to create a mutable object prefrably without ref

2022-11-30 Thread halloleo
Very helpful detail, @Stefan_Salewski. I have read the main chapters of Nim in Action which was good, but I have forgotten quite a bit and it is always good to find out what is "nimonic"... So thanks again!

Polymorphism doesn't work building a dylib for Playdate (Cortex M7) with ARC

2022-11-30 Thread samdze
Thanks! The configuration I posted here is minimal, just to reproduce the issue. I do already use nimAllocPagesViaMalloc (and also build for arm when targeting the device) but didn't know the Playdate is using FreeRTOS! Nice!

Executable crashes unless compiled with -d:release

2022-11-30 Thread ci4ic4
Nim - just built from the latest sources on GitHub: $ nim --version Nim Compiler Version 1.7.3 [NetBSD: amd64] Compiled at 2022-11-30 Copyright (c) 2006-2022 by Andreas Rumpf git hash: 84ea62ea0d64ba454d0f53beb4f3f16d0582ab45 active boot switches: -d:release

Advent of Nim 2022

2022-11-30 Thread auxym
I'm in for sure, AOC is always good fun, especially in Nim. Young kids mean programming time is limited. I'll probably get the first couple days in time, and finish it up after christmas. Still managed to solve all days except 24 last year!