Is there no way to pass a specific overload to a macro?

2021-08-26 Thread Araq
To select a specific overload you can use a type conversion: proc p(a: int) = echo "int" proc p(a: string) = echo "string" (proc (a: string) {.nimcall.})(p)("a") Run

Is there no way to pass a specific overload to a macro?

2021-08-26 Thread treeform
I need your macro knowable! Say I have two functions: proc foobar(x: string): string = discard proc foobar(x: int): int = discard Run I can get the a `ClosedSymChoice` of the `foobar(string)` or `foobar(int)`. To get `foobar(int)` I can just pick

String expression parsing

2021-08-26 Thread Araq
Maybe scanf can be patched to either accept `int` or `Option[int]` for the custom matcher's return type. This would be backwards compatible.

when to use 'ref object' vs plain 'object'

2021-08-26 Thread boia01
> I meant - supported automatically by compiler or VM, not human written hooks. It's not a perfect solution but you could use a `CoW` type to wrap your objects, you don't have to write hooks for every object. You just have to declare your objects as `CoW[MyObject]`. It's not compiler support bu

String expression parsing

2021-08-26 Thread auxym
FWIW, a good resource for writing a relatively simple tokenizer and recursive descent parser from scratch is / I used to to write a parser for arithmetic expressions in last year's Advent of Code, which was massive overkill but interesting.

python: print(x, end=" ")

2021-08-26 Thread Stefan_Salewski
Do we already have something like proc jecho(x: varargs[string, `$`]) = for el in x: stdout.write(el & " ") stdout.write('\n') stdout.flushfile Run in std lib which works also when variables have different data types, as in

String expression parsing

2021-08-26 Thread Stefan_Salewski
I had some success with strscans module. One issue is that the user definable matchers which deliver a result do not work with optional arguments. They have always to return a value greater than zero to indicate a successful match, otherwise all the matching stops. So the string has to always s

using readFile at compile time break exceptions

2021-08-26 Thread timothee
This is precisely what would fix.

using readFile at compile time break exceptions

2021-08-26 Thread giaco
Now I understand where the friction lies

when to use 'ref object' vs plain 'object'

2021-08-26 Thread alexeypetrushin
> Nim does support "copy on write" via custom =hooks. You know what I meant, that it should be done automatically. > But if you don't want to program, why not switch jobs... I don't want to do low-level programming. VM and compilers can do it. Humans have more interesting work to do.

What's Nim's equivalent of Python's append() method for lists?

2021-08-26 Thread Neodim
a &= b Run works as well

Why does this, while incorrect, iterator( code always result in a crash of the playground?

2021-08-26 Thread Araq
Awesome, thanks PMunch!

a == b == c format

2021-08-26 Thread Araq
`b in a .. c` is the encouraged way, yes. I heard the optimizer might still not handle it well but this should be fixed then.

a == b == c format

2021-08-26 Thread Neodim
BTW, what is a Nim-way of a < b < c statement for float vars? The shortest way I found is: b in a .. c Run but maybe there is something proper?

Mac GUI

2021-08-26 Thread Neodim
Hello, Just wonder if there is any progress with Outline View sub widget? Also regarding Table View: it would be awesome to have click/select call-backs as well as move/del of row/column functionality...

heap mgr improved?

2021-08-26 Thread mratsim
> If performance is critical one may consider using memory pools, which allow > faster allocations when all objects have the same size. Mratsim knows the > details. Simple stack-based memory pool when dealloc happens in reverse order of alloc: *

using readFile at compile time break exceptions

2021-08-26 Thread giaco
I don't understand tour point. It seems perfectly legit to me using try/except to readFile at compile time. For example, i know file can be in two locations, so I try first and then second. The point here is that this specific exception is not catched (according to given error) event if excepti

Why does this, while incorrect, iterator( code always result in a crash of the playground?

2021-08-26 Thread PMunch
I think the problem was that before docker killed the container it had already started pumping a log full of numbers. This log was then read in full by the server which OOM-ed it. I have added log truncation to the server now (should've been done a long time ago) and tweaked some OOM parameters

using readFile at compile time break exceptions

2021-08-26 Thread Stefan_Salewski
I was not even aware that exceptions can work at compile-time at all, but then found yesterday this old thread I think I have to read that thread to get an idea what compile-time exceptions can do for me :-)