Accessing object properties where objects are in a sequence

2021-09-10 Thread ftsf
Hi there, this is a thing that's a little bit harder in Nim than some other languages, but here's how you can do it without switching to object variants. import json type Base = ref object of RootObj a: int Child = ref object of Base b: int

Keep a http connection alive and hand it off to another proc

2021-09-10 Thread ingo
Thanks. I use websockets in other projects.

Keep a http connection alive and hand it off to another proc

2021-09-10 Thread treeform
Sorry I can't solve your SSE issues, but I would recommend giving a WebSockets a try. Here is a library I wrote for them: ...

doc2tex

2021-09-10 Thread a_mr
Note that `doc2tex` was added to 1.5.1 devel and will only be available in 1.6 stable release.

Passing JsonNode from Nimscript to host proc

2021-09-10 Thread Araq
To use overloading use something like: proc aInt(x: int) = discard "VM implements it" proc aString(x: string) = discard "VM implements it" proc a(x: int) = aInt(x) proc a(x: string) = aString(x) Run

Call parent `$` from overwritten converter?

2021-09-10 Thread Yardanico
By the way, you don't need it as a converter unless you really want it to convert to string automatically. Echo calls `$` by itself so you can just make it a `proc` instead of a `converter` and your example will work the same.

Call parent `$` from overwritten converter?

2021-09-10 Thread konradmb
Thanks! It's that simple ;)

Call parent `$` from overwritten converter?

2021-09-10 Thread Knaque
`system.`$`(a) ` Run

Call parent `$` from overwritten converter?

2021-09-10 Thread konradmb
I have this code: type Answer* {.pure.} = enum A, B, C, T, N converter `$`*(a: Answer): string = case a: of Answer.T: "Tak" of Answer.N: "Nie" else: $a #How to call parent? echo (A, B, T, N) Run

Passing JsonNode from Nimscript to host proc

2021-09-10 Thread dPixie
Would you suggest that I marshal and unmarshal via string instead? I mean it is straightforward, but it takes a lot of boilerplate code on both sides. I don't mind the boilerplate on the host side, but the script side I would like to keep as clean as possible ... Can you do type overloading on

How do I list the files in a directory in Nim?

2021-09-10 Thread Araq
> I'd say it's better for beginners to see sugar version, as otherwise a person > may see verbose non-sugar version and never look at Nim again. While we need more users and can never have enough users maybe we don't need _every_ user though...

Links of websites built with Karax?

2021-09-10 Thread sdmcallister
I'm using karax to rebuild a site which displays charts and metrics. It is going well and should be deployed in the next 2 months. The site is not public, unfortunately. Before this it was Go templates and vanilla js.

Passing JsonNode from Nimscript to host proc

2021-09-10 Thread Araq
I don't know why you don't get a compile-time error for `value: any` but it's not supported. If you want to `cast` (and you shouldn't) cast the address of the JsonNode to `int` (but `GC_Ref` it first) and use `PNode(kind: nkIntLit, intVal: address)`. And in the VM don't forget to `GC_unref` it.

Passing JsonNode from Nimscript to host proc

2021-09-10 Thread dPixie
Could I for example consider VMArgs as just bits and tell Nim that I want it to cast bit x..^1 as a JsonNode?

I'm having a Nim+Lua+Libtcod callback wrapping problem

2021-09-10 Thread Skaruts
I'm using Love2d and trying to get libtcod to go along with it, so I'm wrapping its functions in Nim (with libtcod_nim). But there's two functions in the pathfinding API that require a callback. This might be straightforward if I was just using libtcod on its own with Nim, but in this case the c

Links of websites built with Karax?

2021-09-10 Thread moigagoo
It seems like there's none sadly. I really like Karax and would love to make something commercial with it, it's just that I don't need it for work and don't have enough spare time or motivation to start something myself.

Passing JsonNode from Nimscript to host proc

2021-09-10 Thread dPixie
Hi @araq. Yes that is ofc one way to do it :) In fact that was basically what I was doing, I had ´setInContext( "some.dot.path", $node )´ in the script call, `proc setInContext*( path: string, value: string ) = discard` in the host function declaration and `let value = args.getString( 1 )` in th

What is the status of Nim IUP?

2021-09-10 Thread Araq
That's news to me. :-)

What is the status of Nim IUP?

2021-09-10 Thread juancarlospaco
IUP does include a browser widget, text editor widget and IDE widget.

Accessing object properties where objects are in a sequence

2021-09-10 Thread Neil_H
Well, switching my program from using standard Objects to Object variants has proved a good move so far, i am able to use Json to save the objects and restore them very easily. The only downside i came across was when passing an object variant to a procedure, Nim would not allow me to use the v

What is the status of Nim IUP?

2021-09-10 Thread Araq
But it was dropped, it's now a Nimble package. Under the nim-lang organization, but still.

Why is backward index operator [^1] not zero based [^0]?

2021-09-10 Thread dom96
> The beauty of Nim is you can define your own backward index operator to > override the normal one that acts like this. Though I'm not sure if the > proposal that made non-system symbols always override system symbols was > implemented, so maybe you can't name it ^ yet. Please don't do this, y

What is the status of Nim IUP?

2021-09-10 Thread marks
Thanks for your replies. Maybe IUP should be dropped from the standard library then?

What is the status of Nim IUP?

2021-09-10 Thread Araq
I would use Fidget, Qt, Gtk3 or wxWidgets instead. The "small and written in C" stuff usually suffers from these problems: * Type unsafe APIs. Welcome to callbacks taking `pointer` arguments. * Type unsafe APIs. Welcome to passing string values instead of enum values for "extensibility" and

Passing JsonNode from Nimscript to host proc

2021-09-10 Thread Araq
Well the PNode does not support JSON, you should be able to pass the JSON as a string though (PNode(kind: nkStrLit, strVal: "{json_here")).

Why is backward index operator [^1] not zero based [^0]?

2021-09-10 Thread Araq
It was indeed decided to be 1-based because of Python and Ruby.

Keep a http connection alive and hand it off to another proc

2021-09-10 Thread ingo
Still trying to bend SSE my way, but running into a problem. I'll try to describe it by the process flow I envisioned. Full code below (using Prologue server) Client connects to web server, GET: sse/. sse accepts and sends back headers, among them keep-alive. Then the connection is added to a l

What is the status of Nim IUP?

2021-09-10 Thread Neodim
Well, I would say it is the awesome library but unfortunately it is not maintained for years. But it may be downloaded and set up manually at . It works perfect with Windows and Linux platforms, but I could not compile it on MacOS. Note, that you will need to

Why is backward index operator [^1] not zero based [^0]?

2021-09-10 Thread Hlaaftana
It's analogous to the index `-1` in languages like Python and Ruby, and the simplicity of subtracting from the length.

What is the status of Nim IUP?

2021-09-10 Thread marks
The standard library documentation includes bindings to the IUP GUI library. However, no direct downloads are provided, not is there any information on how to build a Nim IUP GUI application with IUP either statically or dynamically. Are these bindings maintained? Is IUP the official GUI librar

Why is backward index operator [^1] not zero based [^0]?

2021-09-10 Thread filip
This might be controversial but if the first element is [0] I think the last element should be [^0]. Intuitively I would expect a[^n] == reversed(a)[n] Run Not really a question, more an opinion, but usability and intuition matters to me.

Why is backward index operator [^1] not zero based [^0]?

2021-09-10 Thread haxscramper
I think that's because `mySeq[^1] == mySeq[mySeq.len - 1]`, so simply subtracts from `.len`