Negative number as program argument

2023-03-17 Thread Araq
Where is the problem: include std / prelude var number = 0 for i in 1 .. paramCount(): number = parseInt(paramStr(i)) echo "last number is ", number Run Your dash handling doesn't fit `parseopt`, can happen. So use the primitives instead and

Any way to implement `=` in the follow exampĺe?

2023-03-17 Thread Hlaaftana
> Can i raise an exception when create a variable with zero length e.g. > PasString[0] ? You can define it as `PasString*[n: static range[1..255]]` however unfortunately this does not create an error on `PasString[0]`. > Is there any way to change operator `<<` by `=` ? The actual operator `=`

Any way to implement `=` in the follow exampĺe?

2023-03-17 Thread guaracy
type PasString*[n: static byte] = object size: byte content: array[n,char] proc `<<`*(s:var PasString, v:string)= s.size=v.len.byte if s.size > 0: for ix,c in v: s.content[ix]=c proc `$`*(s:PasString):string= result = newString(

Do you miss these compact syntaxes?

2023-03-17 Thread alexeypetrushin
I meant code like this: type Person = object name: string group: string let name = "Jim" let a = (name: name, group: "a") # let a = (name, group: "a") let b = Person(name: name, group: "b") # let b = Person(name, group: "b") Run

Do you miss these compact syntaxes?

2023-03-17 Thread carterza
JavaScript is a weakly typed dynamic language so syntax like `let another_person = { name }` or whatever, makes sense. Nim is strongly typed for a reason and that is so that the compiler will catch errors at compile time if I fuck up. What is `{name}` in the example above? What is the expected

Do you miss these compact syntaxes?

2023-03-17 Thread alexeypetrushin
Hmm, I don't see the difference between Nim backends, Nim as abstraction layer, totally hides what's beneath, I don't care if it's C or JS or some other backned, my Nim code is the same.

Do you miss these compact syntaxes?

2023-03-17 Thread carterza
I mean, they fit nicely with the Nim JS backend - I can't say as much about the C/C++ or Objective-C backends.

Do you miss these compact syntaxes?

2023-03-17 Thread ElegantBeef
Ooh the latter is a nice addition to my C inspired struct init macro though it'd be `Foo.init(arrayMem[0]: 0, arrayMem[1]: 1)`

Do you miss these compact syntaxes?

2023-03-17 Thread ElegantBeef
Let's gloss over `something = 1 if expr` or `s := x * x for z of y` like that makes any sense. I personally find echo list.map(`+`) echo "Hello ", name Run much more readable, if only we could solve the procvar issue.

Do you miss these compact syntaxes?

2023-03-17 Thread alexeypetrushin
So, for you this echo list.map do (a:auto, b:auto) -> auto: a + b echo fmt"Hello {name}" Run is more readable than echo list.map do (a, b): a + b echo fmt"Hello {name}" Run

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread carterza
So basically, what you're saying is, we've reinvented stack overflow?

Do you miss these compact syntaxes?

2023-03-17 Thread carterza
I believe the two gripes regarding syntax, highest on my list are: 1. Not being able to do: `callSomeProc(addr(SomeType(x: 0, y: 0)))` 2. Not being able to do something like: `var foo = Foo(arrayMem[0]: 0, arrayMem[1]: 1)` Probably more common gripes if you're interfacing with a lot of

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread Naterlarsen
Chat gpt is not the best at nim (not yet anyway). But quite good at Python. It has a lot more data about python, hence the reason for better performing code.

Do you miss these compact syntaxes?

2023-03-17 Thread alexeypetrushin
Nim recently added long awaited overloadable enums, that was huge improvement. Wonder if there any hope to also evolve syntaxes, make it more expressive? # Destructors let { id, name } = person let [first, rest..., last] = [1, 2, 3, 4, 5] # Shortcut for object creati

Do you miss these compact syntaxes?

2023-03-17 Thread ElegantBeef
Given I have never used most of these, and they're stupidly unreadable, nope I do not miss them. The only thing here I find compelling is destructuring.

Sending Directory Listing over Sockets Help.

2023-03-17 Thread Naterlarsen
Hey, got it working. Thanks for making me think betterlol. Here is what I was able to come up. Not the prettiest but its working. if input[0..3] == "path": var my_path = input[5..^1] for entry in walkDir(my_path): le

Negative number as program argument

2023-03-17 Thread cblake
Cool. Well, just raise issues on the repo if you have any questions. The docs of many details could be better, but the closed issue threads are a vast catacombs.

Why Svelte is far superior than React (Karax)

2023-03-17 Thread alexeypetrushin
I discovered that there's Svelte without magic. It's called Solid.JS, they have good presentations how it (and Swelte) works, [100sec](https://www.youtube.com/watch?v=hw3Bx5vxKl0) and [10min videos](https://www.youtube.com/watch?v=J70HXl1KhWE). > Fwiw I did work on a "reactive" Karax with react

Comparison Rust vs Nim binary sizes for IOT applications (just an FYI if you're interested)

2023-03-17 Thread giaco
Thanks for the feedback. > By the way, another thing about Rust - are you actually sure that build-std > is needed for Rust? Nim has dead code elimination always enabled, so I'm not > sure why do you mention the stdlib explicitly. Afaik, by default Rust links the precompiled stdlib blob statica

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread sdmcallister
> GPT-4 with Karax simple example. I had to tell is about `$` though. import karax / [vdom, jdict] type Person = object firstName, lastName: string proc renderPerson(p: Person): VNode = result = buildHtml(tdiv): text("Full Name: ")

Why does Nim compiler allways depends on another's language compiler?

2023-03-17 Thread mildred
Having worked on another language that targetted the C language, and having looked at that time for a LLVM backend, the most problematic thing with the C backend was when the C code had errors and failed to compile. You get C errors that are difficult to trace back to the original code. However

Negative number as program argument

2023-03-17 Thread sramsay
Well, that's a lot to think about (and I am very new to this language). I know a lot about UNIX and basically nothing about Windows, so I'm really not in any position to say what is and is not "cross-compatible." In fact, I suppose I'm not really sure whether that means "CLI behavior that can be

Make Nim docker images official?

2023-03-17 Thread jpalomaki
Here we go:

Negative number as program argument

2023-03-17 Thread cblake
Well, I called it "parseopt3" 7 years ago because I thought I might try to get it into the stdlib. In the early days, `cligen` was just cligen.nim, argcvt.nim, and then parseopt3.nim. Had I tried to get it in to stdlib (or just tolerated the stdlib diffs), it would have been only 2 modules. At t

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread guibar
The first one is quite close actually. Besides the comprehension, there is the change `math.pi` -> `math.Pi` and `complex` -> `Complex`. import std/[complex, sugar, math] proc fft(input: seq[Complex[float]]): seq[Complex[float]] = let n = input.len if n == 1:

Negative number as program argument

2023-03-17 Thread sramsay
Wow, this looks terrific (not to mention a lot of hard work)! Since you've obviously spent some time thinking about all of this, do you have an opinion on whether the stdlib should support either of these behaviors? The first one (not being able to manipulate the raw argv) feels like an inconve

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread Stefan_Salewski
> chat-gpt is convincingly wrong at best with anything more than basic examples. I was very very positive surprised about the Nim knowledge of GPT, so I immediately added a note at the end of the about section: . GPT seems to write much

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread xioren
Worth noting that neither of those examples compile as is. I don't know how close they are to being correct but it seems chat-gpt is convincingly wrong at best with anything more than basic examples. However I did have it correctly debug a small script I gave it that was deliberately invalid.

Negative number as program argument

2023-03-17 Thread cblake
The nim stdlib parsopt has various deviations from POSIX. You may find more to your liking. `cligen` supports the `--` separator in its `cligen/parseopt3`. Also, when auto-converting string->binary integers from positional params (say to a receiving `seq[int]`

Trying to understand: is it better if IndexDefect is CatchableError or not

2023-03-17 Thread Hlaaftana
Didn't say anything before in lieu of being unproductive but I never understood removing bare `except:` when it was an established feature for basically the entirety of the language's existence and it was also the most concise way of expressing the desired behavior; or why Defect was still an Ex

Negative number as program argument

2023-03-17 Thread sramsay
I have a case where I would like a *NIX command-line program to be able to take a negative number as an argument: numprog -2 Run Normally, the way I'd do this is intercept whatever the argument array is, scan for anything that looks like a negative number, remove it (

All chr() up to 127 returns correct unicode character, but chr([128++]) returns �

2023-03-17 Thread sls1005
It seems that UTF-8 uses 2 bytes to store extended latin characters, and thus not (binary-) compatible with Latin-1. echo len("\u00e6") # 2 Run

module "uing", widget Table: How to add rows from string-sequence

2023-03-17 Thread beckx
i am sorry to steal your time with ask without code! Here's my code - i wanna change the content of my sequence data - but it does not show in my table... from uing/rawui import nil import uing var list: seq[string] = @["dummy"] proc modelNumColumns(mh: ptr Tabl

/usr/lib/nim/lib/system.nim

2023-03-17 Thread tmsa04
Thank you! This seems to work in the nim-git PKGBUILD, at least now it builds pakku-git when I just tried, which is as much testing as it has had, which is to say very little! $ diff -u originalPKGBUILD PKGBUILD --- originalPKGBUILD2023-03-17 14:43:22.201997809 +

module "uing", widget Table: How to add rows from string-sequence

2023-03-17 Thread Araq
Maybe it will help if you share some source code.

Trying to understand: is it better if IndexDefect is CatchableError or not

2023-03-17 Thread Araq
> PS: Just compiled jsony - few pages just of the warning. I am afraid that 80% > of libs will supress it one or another way. This warning should be opt-in indeed.

/usr/lib/nim/lib/system.nim

2023-03-17 Thread shirleyquirk
This is an issue with `nim-git`, i added a [comment](https://aur.archlinux.org/pkgbase/nim-git#comment-906500) the [packaging instructions](https://nim-lang.github.io/Nim/packaging.html) were changed in [this commit](https://github.com/nim-lang/Nim/commit/6c15958a835b645f3acdc3d1d012b10d0df4345

Newbie needs help with locks and gcsafe and segfaults

2023-03-17 Thread gs
Thanks again for the explanation. I am not entirely convinced, because i assume that there are no writes to that global... But there is an other library used inside of that ulid so i have to dig deeper... And in the end i am sure that you are right! in the meanwhile i have found that if i

.o files going missing before linking?

2023-03-17 Thread exelotl
@dwhall256 `R:` is a ramdisk created with IMDisk Toolkit, but the same problem happened when we had a local nimcache in the project directory too.

module "uing", widget Table: How to add rows from string-sequence

2023-03-17 Thread beckx
Hello everybody, i want to create an app with gui. Therefore i use th uing-Library. In my gui there is a button which opens the openfile dialog and a Table with 1 column. As "template" i used the "tables.nim" file from the examples folder in the uing. My application starts and because i haven't

Trying to understand: is it better if IndexDefect is CatchableError or not

2023-03-17 Thread Symb0lica
FWIW, I use a template to catch both CatchableError and Defect, with a check in the module that makes building with options that would make this invalid a compile error. # # catchAll template to replace unqualified try: except: blocks # # Check compile options allow ca

Why does Nim compiler allways depends on another's language compiler?

2023-03-17 Thread mratsim
> Also it adds another layer of needless complexity the need to install and > interface with, for instance, a c compiler. I have yet to see a linux distribution or Mac distribution where installing anything for development or sysadmin doesn't start with installing the C toolchain in something s

Make Nim docker images official?

2023-03-17 Thread jpalomaki
Coming back to the original idea in this thread (official images for Nim), I will go and post an RFC [here](https://github.com/nim-lang/RFCs/issues), and we can go from there. I will record all relevant findings from this thread, as a starting point. Thanks everybody for your comments and inter

/usr/lib/nim/lib/system.nim

2023-03-17 Thread PMunch
This should probably be raised with the package itself

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread Yardanico
Even then it does that incorrectly, Nim never supported this syntax first-hand, it came from std/future (std/sugar now).

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread dlesnoff
var even = @[input[i] | i in 0 ..< n by 2] var odd = @[input[i] | i in 1 ..< n by 2] Run It still uses the old list comprehension syntax :(