Nim proc pointers

2021-01-20 Thread mratsim
Do you want a pointer to a proc or to type-erase your proc as a pointer? For the last case, I don't see why `cast[pointer](a)` wouldn't work, I use this extensively: and also for type-erasing functions in s

Print - a better echo. colors, pretty nesting, refs and cycles!

2021-01-20 Thread drkameleon
Great job! I was absolutely looking for something like that! Well done! :)

Ignore part of tuple without warnings

2021-01-20 Thread lqdev
As far as I can tell from the gensyms, you're trying to do that in a template. Try adding a {.used.} pragma to your variable, like so: let (a {.used.}, b) = getATuple(sth) Run

Ignore part of tuple without warnings

2021-01-20 Thread drkameleon
Basically, I'm doing something simple: let (a,b) = getATuple(sth) Run Then I'm using just `b` and the compiler complains that: Hint: 'a`gensym452' is declared but not used [XDeclaredButNotUsed] Run Which sounds fine. Then I replace the par

Ignore part of tuple without warnings

2021-01-20 Thread drkameleon
Thanks a lot for the suggestions! Yes, it works beautifully! And yep, I have been using it in a template - [as @Araq had pointed out](https://forum.nim-lang.org/t/7337), I have _tons_ of them...

Ignore part of tuple without warnings

2021-01-20 Thread ElegantBeef
I wager you're using a template, those gensym the identifiers created inside them, so the way to stop that is using `{.inject.}` as the following. template test = let (a, _{.inject.}) = (100, 200) test() Run

Ignore part of tuple without warnings

2021-01-20 Thread ElegantBeef
Worth noting that `used` will cause issues if you have anymore than one `_` in the template as the compiler will assume they're all the same. [Used example](https://play.nim-lang.org/#ix=2MFl) [Inject example](https://play.nim-lang.org/#ix=2MFm)

Print - a better echo. colors, pretty nesting, refs and cycles!

2021-01-20 Thread cblake
`isatty` is ok as a way to default colors on/off, but again a run-time override switch to (en|dis)able is better than a compile-time switch. Re-directing to a file or pipe the end user may not want to have to parse or filter out escape sequences. Or on the other hand because there is maybe a lot

Print - a better echo. colors, pretty nesting, refs and cycles!

2021-01-20 Thread greenfork
That is really cool!

UFCS and templates

2021-01-20 Thread ggibson
What's your workflow to know what you can and cannot use UFCS on? And especially how do you teach newcomers UFCS? I am tempted to err on the side of: * Use an IDE (like alaviss' nvim plugin) that shows you the type of what you're writing, and then * Only use UFCS for procs and funcs and NOTH

Ignore part of tuple without warnings

2021-01-20 Thread Hlaaftana
Github issue:

UFCS and templates

2021-01-20 Thread xigoi
UFCS can be used if the left argument is something that by itself has a type. Unfortunately, Nim still doesn't have first-class iterators, which is the reason why you can't use UFCS on them.

UFCS and templates

2021-01-20 Thread ggibson
> UFCS can be used if the left argument is something that by itself has a type That is more or less how I think about it when programming Nim. Is that phrasing how you would recommend teaching newcomers about UFCS?

libdill for large scale concurrency

2021-01-20 Thread kobi
There is a c library called libdill / it provides go-like coroutines with very similar behaviour, and has excellent performance. Nim has macros, that can make such a wrapper look and feel like a first class citizen, like a part of the language. Along side the heavier thread m

libdill for large scale concurrency

2021-01-20 Thread lqdev
Sounds like something that could be implemented on top of [Weave](https://github.com/mratsim/weave).

Nim Community Survey 2020 Results

2021-01-20 Thread miran
https://nim-lang.org/blog/2021/01/20/community-survey-results-2020.html

Admin for web app

2021-01-20 Thread vinyll
Yes, it's mostly CRUD. I currently use Django admin and it's for basic administration of content for users who don't want to break the database. Would be great to see your work in progress @jasonfi. Is is based on a specific framework or database or is it very generic?

How to convert const char * to string?

2021-01-20 Thread cdunn2001
I hit the same problem a long time ago. IIRC, I had to do this: let cstr = foo.asCstring() nimstr = $cstr Run I never learned why `$()` didn't work, but sometimes the parser has trouble. Not too big a deal.

Nim proc pointers

2021-01-20 Thread minidude22
I'm attempting to type-erase a proc as a pointer. In my second example you can't even do: let a = add Run Nim says `invalid type: 'None' for let`

libdill for large scale concurrency

2021-01-20 Thread cumulonimbus
libdill manipulates the C call stack in various ways; I suspect you can use it "as is" through FFI when using the C backend(s), but there's likely not going to be any way to use it from JS or NimVM. However, there's a rather promising pure-nim library which gi

Admin for web app

2021-01-20 Thread alexeypetrushin
I'm also need something like that. Thinking about maybe using Headless CMS (like Admin UI in React.JS in TypeScript) + Nim REST API. Creating it in Nim would be nice, but feels like a too big task..., it feels easier to adopt something already made

Nim Community Survey 2020 Results

2021-01-20 Thread miran
> lower than in 2019 For 2019 we ran it for 50 days. This year it was 30 days. > lower than in 2018 Really? 2 persons less (769 vs 771) is 0.26%. C'mon.

Nim Community Survey 2020 Results

2021-01-20 Thread slonik_az
Participation in this survey was lower than in 2019 and 2018. I am curious what could be the reasons (beyond covid of course).

Nim proc pointers

2021-01-20 Thread xigoi
Have you tried naming it something else? There is already a proc named `add` in the system module, so this will create an overloaded proc, which obviously can't be assigned.

UFCS and templates

2021-01-20 Thread xigoi
Honestly, I'd probably just teach them how it works in general and when they crash into this issue, explain why it doesn't work here.

Nim Community Survey 2020 Results

2021-01-20 Thread digitalcraftsman
To someone who was evaluating the survey results: did you received any interesting insights, ideas, feedback etc. via the free text fields? Often times those are the most interesting data to read because a participant isn't bound to a question's predefined answers. The survey results however re

Admin for web app

2021-01-20 Thread alexeypetrushin
I'm hoping one day someone in Nim would adopt approach pioneered by Phoenix LiveView, that allows to create a lot with very little code. It's better to showcase by example, take look at gif and the full code it's made with Advantages v

Admin for web app

2021-01-20 Thread jasonfi
It's written in Jester/Karax, and I'm working on supporting multiple databases. Anyone interested in getting an update when it's ready, just email me at jason.fi...@gmail.com and I'll let you know.