Collect a seq and use it straightaway?

2021-06-29 Thread halloleo
Given a `seq[string]` `txts` I have the following code: let withBullets = collect(newSeq): for s in txts: &"* {s}" dialog "Here is what happened:\n" & withBullets.join("\n") & "\nDo you understand?" Run In Python I could write: dialog "Here is w

Life is a struggle - a struggle with Nim (video)

2021-06-29 Thread cdunn2001
re: > Is it used in production, or am I going to be the first to test it properly? My company uses it for some production code. I have never had a single problem with it. In my opinion, the global threadpool should be grounded. It writes checks that th

Life is a struggle - a struggle with Nim (video)

2021-06-29 Thread cdunn2001
> Not necessarily. It makes sense from the point of view of functionality - > i.e.: you want to limit the number of CPU-bound threads in your application, > so you can use your CPU cores efficiently. I cannot tell the program how many threads to use until inside `main()`. Using all CPUs is ofte

Life is a struggle - a struggle with Nim (video)

2021-06-29 Thread cdunn2001
You've overlooked the advantages of letting the compiler avoid the overhead when it's provably unnecessary, which is the typical case. When RC is truly a poor solution, you can use Boehm-Weiser instead.

How to get Name and Value from Variable for macro/template

2021-06-29 Thread Niminem
Thanks for the feedback guys, ever since I started playing with `nim secret` I know this is the route I want to go and it doesn't need exporting of symbols... it's a REPL!

How to get Name and Value from Variable for macro/template

2021-06-29 Thread Niminem
I'd like to use `nim secret` as the REPL for the IDE but I get stuck trying to print out the output stream (the process is called via startProcess and I have two variables- 1 for the input stream 1 for the output) Is there a good source for handling like... sending and receiving messages to/fro

Question with nimpy

2021-06-29 Thread stbalbach
Given this, importing "numpy" works but "pandas" does not: import nimpy/nimpy let np = pyImport("numpy") let a = np.mean([1, 2, 3]) let f = np.sin(a) echo "numpy check" echo f let pd = pyImport("pandas") let df_temp = pd.DataFrame({"A": 1, "B": 2}

Trying to understand compilation error "Error: no tuple type for constructor"

2021-06-29 Thread stu002
Here's a Nim playground of (probably non-idiomatic) Nim using concepts. Line 45 gives a "Error: no tuple type for constructor" error which I'm struggling to understand given the previous type and function declarations in that snippet. Can anyone advise? Ta,

Improving the documentation: Roadmap, community engagement.

2021-06-29 Thread timothee
> I remember when the "Edit" button on our documentation was considered to be > so essential that poor Araq went ahead and implemented it. For years now we > have this nice Edit button on everything. I think we got about 5 PRs in total > more thanks to this button. @araq the main use case (at l

How to get Name and Value from Variable for macro/template

2021-06-29 Thread dsrw
Personally, I'd say that only exported symbols are usable in future cells, and then I'd load each cell in its own module and have each module automatically import all previous modules/cells. Advantages: * Very easy. * Works without any parsing or macros. * You get cell/module local variab

What does "" sign mean?

2021-06-29 Thread xflywind
It should be already removed at devel.

Advice on OOP in Nim

2021-06-29 Thread JPLRouge
Strongly agree with you, this is really something that should be "tapped" to do NIM programming. Me in old times this was called ROO (object-object relation coupled with the notion of the theory of "sets")

How to get Name and Value from Variable for macro/template

2021-06-29 Thread ynfle
Why don't you just have a macro that marks the variable as exported?

How to get Name and Value from Variable for macro/template

2021-06-29 Thread ynfle
Simple macro to get symbol name. macro getSymbolName(x: untyped): string = x.toStrLit Run I'm not sure if I get what you want for getting the latest value.

How to get Name and Value from Variable for macro/template

2021-06-29 Thread Niminem
Awesome thanks for some direction, I'll continue my research from here

How to get Name and Value from Variable for macro/template

2021-06-29 Thread timothee
see * `tests/compilerapi/tcompilerapi.nim` which might be what you want * `nim secret` seems relevant * `moduleSymbols` () which allows getting all symbols (private or not) from a module, including variables

How to get Name and Value from Variable for macro/template

2021-06-29 Thread Niminem
Thanks, I wasn't clear enough though. I need to do this programmatically. I have a [Jupyter Notebook-like IDE](https://github.com/Niminem/NimNotebook) I'm building. It uses embedded nimscript, passing data (module1 scenario) to the backend for execution. What I'm trying to include now is the ab

How to get Name and Value from Variable for macro/template

2021-06-29 Thread timothee
# module1: var name* = "Leon" name = "Blane" # module2: from moduel1 import nil var name = moduel1.name Run

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread Niminem
+1 for using macros. I'm currently doing something like this. I'm trying to integrate Plotly with a Jupyter Notebook-like IDE I'm making. The DSL so far looks something basic like: plot LineGraph: x:[0,1,2,3,4,5] y:[0,1,2,3,4,5] Run You can abstract away A

How to get Name and Value from Variable for macro/template

2021-06-29 Thread Niminem
Hey guys, I'm trying to get the name and latest value from a variable, and write a variable declaration in a new file with this information. Like so: `module1.nim` `var name = "Leon"` `name = "Blane" # I want this value, not the value it was instantiated with` `module2.nim` `var name = "Blane"

Formatting a float to currency

2021-06-29 Thread timothee
> But the code is pretty bad, both slow and hard to understand.. it can be improved during code review; at least it seems more correct than which I kept breaking during code review

Type-safe DSL / Data Schema

2021-06-29 Thread dsrw
You probably want [macros.expectKind](https://nim-lang.org/docs/macros.html#expectKind%2CNimNode%2CNimNodeKind) or [macros.error](https://nim-lang.org/docs/macros.html#error%2Cstring%2CNimNode). When you have the `NimNode` that you're interested, either pass it to `expectKind` or do whatever c

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread dsrw
This is a bit of an aside, but you could implement this whole TS feature with Nim macros. Rather than writing a DSL for plotting, you could write a macro that takes a schema and produces types and a DSL using a pretty similar format to TS. It might be a decent amount of work, and I'm not sure if

Type-safe DSL / Data Schema

2021-06-29 Thread alexeypetrushin
I mean - in the example above the data is known at compile time. Of course when there's dynamic data, there's no way to check the types.

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread alexeypetrushin
I just realised there's one more reason why I would like to use pure data API instead of specialized DSL. Just a nice and compact way to build data structures. Because if you work with plots and data analysis, you probably spent at least 50% of the time with Python and/or JS/TS. And you don't w

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread alexeypetrushin
There's a significant difference between Vega-Lite and other plotting libraries like Matlab, matplotlib etc. Vega-Lite is visualisation grammar, a set of primitives that could be combined and composed in many different ways. Other plot libs are predefined boilerplates, want scatter - use templa

What does "" sign mean?

2021-06-29 Thread exoticisotopic
It is an template to make compile. Seems to be a just a sign for comatibility. [Nim](https://nim-lang.org/docs/system.html#%3C%2F%2F%3E.t%2Cuntyped)

What does "" sign mean?

2021-06-29 Thread exoticisotopic
When I looked into the source code of Nim module `tables`, I found the sign in some procedures. What does it mean and are there any other scenarios to use it? proc newTable*[A, B](initialSize = defaultInitialSize): TableRef[A, B] = ## Creates a new ref hash table that is emp

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread Vindaar
> It would be really great if there were a karax-style DSL for plotting. Even > better if it supported multiple backends like vega/vega-lite. Who _really_ wants something as verbose as karax or raw vega-lite as a plotting tool though? This: was an attempt

nim-ws - websockets for Nim

2021-06-29 Thread enthus1ast
Its a SOCKS server and a small client. To make the SOCKS client really usable, the `Proxy` ( ) should be upgraded to also support SOCKS (or third party generic Proxy implementations)

Type-safe DSL / Data Schema

2021-06-29 Thread juancarlospaco
If the data is known at compile-time, it can be done with `doAssert` or similar. If the data is not known at compile-time, it may require time travel.

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread juancarlospaco
> macros are just too hard One of the big benefits of Nim is the awesome metaprogramming, maybe read about: * * * quote do and dumpastgen

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread alexeypetrushin
Yes. I do use Vega-Lite too, it is awesome. But I don't like DSL (I used DSL heavily in Ruby, but don't use it anymore). After working with TypeScript kinda homoiconic-like data format, with 1-to-1 match with language types, fully type-safe and 100% IDE autocomplete and with literal types. It's

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread sdmcallister
It would be really great if there were a karax-style DSL for plotting. Even better if it supported multiple backends like vega/vega-lite.

Type-safe DSL / Data Schema

2021-06-29 Thread alexeypetrushin
I discovered that it's possilbe to define complex data schemes in Nim, and being able to validate it against Nim types. The problem is that it's validated only at runtime. Is there a way to make it to be type-safe and validated at compile time? Example, in the code below, there's a mistake, the

Nim 2.0 -- thoughts

2021-06-29 Thread Sixte
> What? Sorry, but what? I meant that caring about correctness is not > pre-mature, in other words: it's never too early to care about correctness. Of course, correctness is never debatable itself. I translated @freeform 's "premature" as "when to resolve". Otherwise, his post would not make se

Nim 2.0 -- thoughts

2021-06-29 Thread planetis
There is though

Is there a way to build better Nim DSL for plotting?

2021-06-29 Thread alexeypetrushin
I found one more way. And used the `std/json.%*` (I altered it a little bit to avoid the need for quotes for object keys and called `jo`). So the new Nim API: plot("/portfolio.json", jo { order: [["mv_usd", "desc"]], columns: [ { id: "mv_usd",

nim-ws - websockets for Nim

2021-06-29 Thread arnetheduck
well, all is not lost because is on our roadmap, to be able to access tor and similar service

Associating a type with a concept?

2021-06-29 Thread Sixte
> the change i made was removing the non-generic overloads and adding > doEp(12,13) i removed the specializations from your original version as the > generic was never getting called. I didn't remove them. Anyway, how to express in the concept, that T is distinct from the types for x and y ?

Nim 2.0 -- thoughts

2021-06-29 Thread Sixte
This still gives headaches to me: > If everything reachable is also visible then changing the set of imported > modules is always a breaking change for any "downstream" modules since they > can all name things from those modules without actually importing them. It > also greatly increases the r

Nim 2.0 -- thoughts

2021-06-29 Thread Araq
> A remarkable statement. Translation: "Resolve as late as possible". What? Sorry, but what? I meant that caring about correctness is _not_ **pre** -mature, in other words: it's never too early to care about it.

Associating a type with a concept?

2021-06-29 Thread shirleyquirk
the change i made was removing the non-generic overloads and adding `doEp(12,13)` i removed the specializations from your original version as the generic was never getting called. I'm not surprised that the first one doesn't compile, as i'm trying to call `

Nim 2.0 -- thoughts

2021-06-29 Thread Sixte
> And I don't believe in "premature correctness". ;-) Interesting statement. Translation: "Resolve as late as possible". This indeed has consequences for both language and compiler design. E.g. for incremental compilation. The compiler collects packed AST parts . At the very end, they get check

Nim 2.0 -- thoughts

2021-06-29 Thread Araq
Unfortunately I can only upvote you once. :-) Yes, yes and yes. (And no for the general memory pool idea.) > My preferred option is to replace the whole file with something that works Yes. > However, the need for allocation from a sized memory pool is frequent enough > that I think that there

Associating a type with a concept?

2021-06-29 Thread Sixte
> results in a type mismatch, as does ?? You made a minimal change - you imported strformat - it compiles anyway.

Nim 2.0 -- thoughts

2021-06-29 Thread GordonBGood
> > I understand one needs to get some sort of invitation or make some sort of > > application? > > You need to create a pull request here: **Before polluting the blog space with some inconclusive ranting ;-)** , I want to continue trying to resolve the iss

nim-ws - websockets for Nim

2021-06-29 Thread Araq
Is it too late for bad puns? Why not name it "nimsocks" and then later you can layer something on top of it and call it "nimshoes".