atlas/nimble build still tries to download dependencies despite nim.cfg

2023-09-26 Thread elcritch
I've taken to creating a `build.nims` and putting build tasks in there. Then I 
include it in both `config.nims` and `project.nimble`. That way you can do `nim 
build` or `nim test` in addition to `nimble build`.


atlas/nimble build still tries to download dependencies despite nim.cfg

2023-09-26 Thread Araq
> If the intended process (at least for now) is to just use nim c then I think 
> that resolves my question, thanks!

That is indeed the intended process and not an interim solution either, it's 
Atlas's key feature and design aspect. It means Atlas does not have to 
replicate `nim c`, `nim cpp`, `nim js`, `nim check` and `nimsuggest`. It is the 
key behind Atlas's simplicity.


Simple template and macro question

2023-09-26 Thread dlesnoff
> Is there a way to actually see the expanded Nim code. Like your comment

Do like the code snippet above. Return the `repr` of the Nim's AST.


Improving Examples and Documentation

2023-09-26 Thread cmc
That's a really neat theory about documentation aversion. Reading your 
explanation, I got a hunch that maybe it's because considering others 
emotionally is built-in, while considering others cerebrally is rather hard 
work that can lead to overthinking and other problems so people throw in the 
towel.

There seems to be broad agreement that good docs contain tutorials, how-to 
guides, and a reference. I've never heard about explanation mentioned 
separately but it makes total sense- [I'll add 
it](https://github.com/nim-lang/Nim/issues/22720) . Your rationale for having 
tutorials sums it up nicely, adding that as well. 


Improving Examples and Documentation

2023-09-26 Thread cmc
Hahaha yeah, another Supercollider user! I learned the hard way to read the 
source instead of the docs using SuperCollider! It worked wonders for Nim as 
well! I know what, we'll just scrap the whole documentation thing and have Nim 
marketing exclusively target SuperCollider users, then we can cut out about two 
thirds of the manual as well.

SuperCollider-style offline docs is a great idea- this ties into tooling, 
having docs while typing seems to be rather popular, I'm assuming vscode 
doesn't have this yet for Nim.


ImPlot library

2023-09-26 Thread galaxyDragon
I'v made [ImPlot library binding](https://github.com/dinau/nim_implot) for Nim.

[ImPlot](https://github.com/epezent/implot) is an immediate mode, GPU 
accelerated plotting library for [Dear ImGui](https://github.com/ocornut/imgui) 
.

Running examples:


nimble install https://github.com/dinau/nim_implot
git clone --recursive https://github.com/dinau/nim_implot
cd nim_implot
nimble test


Run

Some of examples:

[examples/LinePlots.nim](https://github.com/dinau/nim_implot/blob/main/examples/LinePlots.nim)

[examples/LogScale.nim](https://github.com/dinau/nim_implot/blob/main/examples/LogScale.nim)


Simple template and macro question

2023-09-26 Thread dlesnoff
There is nothing in your code saying that T should be char and R should be a 
string.

Parser seems to be a generic type that is not specialized. Shouldn't that be:

1\. Just to see if it works correctly:


template generate(body: untyped): untyped =
  block:
proc temp[T, R](stream{.inject.}: Stream[T], index{.inject.}: var int): 
Result[R] =
  `body`

Parser[char, string](fn: temp, description: "")


Run

2\. If we can do generic templates:


template generate[T, R](body: untyped): untyped =
  block:
proc temp[U, V](stream{.inject.}: Stream[U], index{.inject.}: var int): 
Result[V] =
  `body`

Parser[T, R](fn: temp, description: "")


Run

Don't forget to specialized in the main program:


let t: Parser[char, string] = generate[char, string]:


Run


how to static linking sqlite ?

2023-09-26 Thread aiac
  * error info








Run

  * my Dockerfile




FROM nimlang/nim:2.0.0-alpine as builder

WORKDIR /project

RUN apk add --update --no-cache --force-overwrite sqlite-dev sqlite-static

COPY . .

RUN nimble build -d:beast -d:release --mm:refc -d:nimDebugDlOpen 
--passL:-static --verbose -y



FROM alpine:latest

WORKDIR /app

COPY --from=builder --chmod=777 /project/test_happyx ./bin/
COPY --from=builder /project/fighter.db ./

EXPOSE 5000/tcp

ENTRYPOINT ["./bin/test_happyx"]


Run


how to static linking sqlite ?

2023-09-26 Thread aiac
I don’t know why, but the forum’s markdown editor keeps eating my text.

error info here when start container :


Dynamic loading not supported
Dynamic loading not supported
could not load: libsqlite3.so(|.0)


Run


[newbie] go to definition is not working on vscodium on EndeavourOS(Arch based distro)

2023-09-26 Thread Levlan
Is it because of nim on vscodium (vscode)? or something related to EndeavourOS?


Simple template and macro question

2023-09-26 Thread CircArgs
For `repr` though, it seems is has to be in a macro (I'd been using it before 
asking this question actually and I didn't even put together that the `gensym` 
I was seeing was actually modifying the identifiers!)

🤔 I suppose I can just make a utility macro for the repr in which case I guess 
my question is just "does a utility already exist that does this in global code 
like dumpAst?"

These posts: recent:  older: 


might have been another.

I thing the generic template will work. I'll try that.

> There is nothing in your code saying that T should be char and R should be a 
> string.

sorry here is the definition of `Parser`


ParseFn*[T, R] = proc(stream: Stream[T]; index: var int): Result[R]
Parser*[T, R] = object
  fn*: ParseFn[T, R]
  description*: string

Run

Here is my logic on how the type could have been inferred:

(forgive some adhoc notation) `Parser[T, R](temp[T, R]) -> block[Parser[T, R]] 
-> t: Parser[char, string]`

in my mind, the information is all there if the type checker can walk this 
chain in reverse.


ImPlot library

2023-09-26 Thread hamidrb80
Amazing! please publish it to Nimble


how to static linking sqlite ?

2023-09-26 Thread Allin
Lines 68-103 of SQLiteral should effectively guide you towards a solution:




how to static linking sqlite ?

2023-09-26 Thread aiac
Thanks a lot, it seems helpful for compiling sqlite3.a.

In my case, we have already got it by 


 add sqlite-static

Run

so I found that I just need to modify it like the following and it will work 
well

> 
> RUN nimble build -d:beast -d:release --mm:refc -d:nimDebugDlOpen 
> --dynlibOverride:sqlite3 --passL:/usr/lib/libsqlite3.a --passL:-static 
> --verbose -y
> 
> 
> Run


ImPlot library

2023-09-26 Thread didlybom
This is cool but can I ask why do the plot functions receive the address of the 
data they must plot?


ImPlot library

2023-09-26 Thread Vindaar
Nice! Always great to see more plotting libraries! Do you intend to write a 
high level interface for it at some point?

And just out of curiosity, do you know what performance actually looks like 
when you plot large amounts of data? Does it handle that better than all 
standard scientific plotting libs (where that is not of importance usually)?


Simple template and macro question

2023-09-26 Thread nrk
> Is there a way to actually see the expanded Nim code.

Maybe try 
[expandMacros](https://nim-lang.org/docs/macros.html#expandMacros.m%2Ctyped). 


Simple template and macro question

2023-09-26 Thread Zoom
The explanations in this thread are great and the only logical next step is to 
add it all to the official tutorials.


[newbie] go to definition is not working on vscodium on EndeavourOS(Arch based distro)

2023-09-26 Thread amkrajewski
Not an answer really, but I hope an extra data point helps. I'm using Nim 2.0.0 
in VS Code (1.82.2) with Nim extension (the one by nimsaem) on MacOS (Darwin 
22.5) and the "Go to Definition" works as intended.


Simple template and macro question

2023-09-26 Thread CircArgs
Kinda close, but the description says

> will actually dump x + y, but at the same time will print at compile time the 
> expansion of...

its definition is just


echo body.toStrLit
result = body

Run

and it takes `typed` and I can't avoid compiler errors while using it. What I 
was hoping for is something that will fully expand all the code so you can see 
what the code would look like with the macro expanded **even if the expanded 
code is invalid** which seems crucial to debugging especially for a beginner 
like me. That's why I referenced `dumpAst[Gen]` because it is a good teaching 
tool.

So, I tried these (macros all commented out):


# 1. shows everything but just as written e.g. not expanded
# macro echoMacro(b: untyped)=
#   echo repr(b)
# 2. (produced same as 1)
# macro echoMacro(b: untyped)=
#   echo b.toStrLit
# 3. raises the compiler errors without showing anything
# macro echoMacro(b: typed)=
#   echo b.toStrLit
# 4. at this point I'm reaching because idk what I'm doing :)
# and this isn't valid according to the compiler
# macro echoMacro(b: untyped)=
#   let expanded = expandMacros:
#   echo expanded.toStrLit

echoMacro:
  let t: Parser[char, string] = generate:
let x = step test_string("he")
discard step "ll"
let s = step "o"
return x&s
  
  echo t.parse("hello")

Run

@dlesnoff I realized I had already run your experiment (1) and it had worked. 
Your #2 worked too!

Would you mind explaining the distinction between the generic parameters of 
something like a template/macro vs the actual template/macro arguments? My 
initial thoughts looking at generic parameters for such a thing is not for 
using them in the actual template but for using them to type arguments and 
return types so this solution never would have occurred to me.

For example, I had even tried these before your answer, but they didn't work:


template generate(T, R, body: untyped): untyped =
  block:
proc temp(stream{.inject.}: Stream, index{.inject.}: var int): Result =
  `body`

Parser[T, R](fn: temp, description: "")

template generate(T, R: typedesc; body: untyped): untyped =
  ...same body


let t = generate char, string:
  ...

Run


atlas/nimble build still tries to download dependencies despite nim.cfg

2023-09-26 Thread woolsweater
> That is indeed the intended process and not an interim solution either, it's 
> Atlas's key feature and design aspect.

Got it, thanks! I assumed that the `atlas build` command would be the new way. 
I am curious to see what that command is renamed/turned into.


atlas/nimble build still tries to download dependencies despite nim.cfg

2023-09-26 Thread woolsweater
This sounds great; do you happen to have a public repo using this technique 
that I could look at?


ImPlot library

2023-09-26 Thread Neodim
Looks very promising! Is it possible to make an "interactive" point on the plot 
which calls back a function or specific pop-up menu upon clicking?