Indentation in Nim

2021-11-05 Thread aEverr
what exactly is your point? you just rebutted both of your options

Indentation in Nim

2021-11-05 Thread Cusaint
I think that people do not like indentation is because copying and pasting code from webpages and other sources (maybe from PDF files) might not let the copying of the code correctly. Therefore it will not be pasted as it should (and then the code will/might not run as it is supposed to). Files

createDir on Windows using URL

2021-11-05 Thread alpine
Yep, works with std/winlean as suggested. Thanks! Interesting. Probably should report as a bug for std/os...

Nested Tables

2021-11-05 Thread SunnyCorleone
I dont mind the default value behaviour, although obviously it shouldnt happen when looking up a key or checking the length.

How to make a proc with a default genetic type that can be inferred at compile time?

2021-11-05 Thread ElegantBeef
This problem might be better handled with a static enum, as it gives you a typeclass and also language specific dispatch. type Locale = enum Unknown, English, French Language[T: static Locale] = distinct string proc readFile(path: string; locale: static

createDir on Windows using URL

2021-11-05 Thread sky_khan
No idea whats wrong with std/os but this works: import std/winlean let testFldr = "KHANDESKW\\Shared\\helloworld" let ws = newWideCString(testFldr) let r = createDirectoryW(ws,nil) if r != 0: echo testFldr & " created" else: echo "Error"

Survey Question: flow research

2021-11-05 Thread quantimnot
Regarding the `nim-gdb` script. I only works if you have a compatible `readlink` (I don't on macos) and a GDB built with Python support, which I have learned that many that are pre-built for Windows do not. See the following links for more discussion about it and workarounds for loading the `n

Windows Sapi 5 - com unclear (new to Nim - programming with Nim after Python proof of concept)

2021-11-05 Thread VVX7
sorry to necro/hijack this thread. hey, @ward how can I get in touch?

createDir on Windows using URL

2021-11-05 Thread treeform
And maybe the \ ?

createDir on Windows using URL

2021-11-05 Thread alpine
Hmm, thanks but not seeing your point. The backslashes are valid Windows path separators, not part of the directory names themselves. They are doubled in the strings vars code as they need to be escaped. The Nim function dirExists("") works just fine and finds the path. I'm starting to

createDir on Windows using URL

2021-11-05 Thread treeform
I think its the `<` `>` that is giving you issues.

New here

2021-11-05 Thread SebastianM
Yes, I was referring to multiple types as values. Probably not good idea to use it like that, but curiosity won :)

createDir on Windows using URL

2021-11-05 Thread treeform
`md` is probably a linux cygwin command that gets around it maybe? `md` should fail as well.

createDir on Windows using URL

2021-11-05 Thread treeform
You are using characters that are not valid as path name: As you can see way more characters are invalid on windows then linux: < (less than) > (greater than) : (colon - sometimes works, but is actually NTFS Alternate Data Streams

Compute a Sha256 : the fastest implem ?

2021-11-05 Thread arnetheduck
We're currently using which is ok because of its good platform support and decent performance, but there are faster options out there:

createDir on Windows using URL

2021-11-05 Thread alpine
I'm trying to create a directory using the URL form of path \\server\share\folder Run but getting exceptions: C:\Apps\nim-1.6.0\lib\pure\os.nim(2552) createDir C:\Apps\nim-1.6.0\lib\pure\os.nim(2522) existsOrCreateDir C:\Apps\nim-1.6.0\lib\pure\o

Survey Question: flow research

2021-11-05 Thread Fire
100%

New here

2021-11-05 Thread miran
> E.g: for python dict you use nim json module. Python's dicts can/should be replaced with [Nim tables](https://nim-lang.github.io/Nim/tables.html). I think I have never used json module for that.

Survey Question: flow research

2021-11-05 Thread Niminem
I say C/C++/JS FFI needs some serious help regarding examples and walkthroughs. I get my ass kicked for days before I figure out how to get something working sometimes :D

Compute a Sha256 : the fastest implem ?

2021-11-05 Thread manatlan
Hi .. I know that I could test it my way ... But perhaps, someone has already do it ?! When computing sha256 ... on my computer I reached to compute 10M of sha256 in less than 7 seconds ... with nimSHA2. But I would like to know if there are others implentations which could beat that ? because

Best way to turn byte array into int?

2021-11-05 Thread shirleyquirk
What about: import std/sysrand proc urand[T]():T = assert urandom(cast[var array[sizeof(T),byte]](result.addr) Run for value types only

Best way to turn byte array into int?

2021-11-05 Thread xioren
Think this will work for me, thanks.

New here

2021-11-05 Thread SebastianM
Yes, That's true in Python - that's why in Nim there is some effort to make things work. E.g: for python dict you use nim json module. But the documentation is great enough that some deeper digging can bring the solution. And it's really worth it.

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread exelotl
The disadvantage of `import`/`export` is that you lose the module names. For example you could do: include std/prelude echo times.fromUnix(0) Run But if it changed to `import common` you'd have to write this instead: import std/common ec

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread arnetheduck
We recommend import/export throughout - but rather than using a single prelude, we build a hierarchy (preludes are kind of ugly in general because they include stuff you don't need and often miss stuff you do need).. gives some

Best way to turn byte array into int?

2021-11-05 Thread ggibson
Here's what I use. I expanded my types so you can see the raw array. func read(this:var array[SIZE, byte], T:typedesc, pos:Natural = 0):ptr T = result = cast[ptr T](addr this[pos]) Run

Best way to turn byte array into int?

2021-11-05 Thread xioren
Playing around with the new urandom proc from sysrand and am wondering how best to go about turning the returned byte array int a single int. I have a couple ideas but none seem like "the right way".

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread didlybom
As a somewhat new user I’d find much more logical and easier to understand having to use “import std/common” as a way to _[import](https://forum.nim-lang.org/postActivity.xml#import) a few common modules. Otherwise you need to learn and remember that to _[import](https://forum.nim-lang.org/post

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread Araq
Generally, no you should not use `include` over `import`, but for prelude or a prelude-like thing it's what I prefer. IIRC I did the same for Karax, maybe it got changed later via a PR. If prelude did `import ; export ` then it should be a file you should `import`, not `include`. So maybe turn

This forum preview JS error

2021-11-05 Thread gyohng
Yes, that was one of the browser extensions indeed, thanks.

Query nim include paths

2021-11-05 Thread gyohng
Thanks, that's really helpful. I'll use the suggestions.

Karax : convert html string to vdom

2021-11-05 Thread Cnerd
Hi so after some thought i have created a library called htmlToVdom which converts html string to embbedable karax representations. I have tested it and it works well. So if you ever need the library here's the link to the github page . I have also made a p

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread didlybom
BTW, simply adding: > export os, strutils, times, parseutils, hashes, tables, sets, sequtils, > parseopt, strformat At the end of prelude.nim fixes _[both](https://forum.nim-lang.org/postActivity.xml#both) of the issues I had (i.e. import now works and also I don't get the "imported and not us

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread didlybom
Sorry @Araq, I don't understand what you mean when you say that you don't like the import / export idiom. Are you saying it is best to use include rather than import?? I'm a bit confused by your statement.

How to make a proc with a default genetic type that can be inferred at compile time?

2021-11-05 Thread benjamindlee
That's a great solution! Do you know of any examples in the stdlib that use this approach? I haven't seen it before in practice. It does still seem strange though to me that there's not a way to use the regular `name[T](arg)` call if you want to, only `name(arg, T)`. Is there a reason it can't

How to make a proc with a default genetic type that can be inferred at compile time?

2021-11-05 Thread demotomohiro
How about to use `typedesc` parameter? type English = distinct string type French = distinct string type Language = distinct string type OpenLang = Language|English|French proc readFile(filepath: string; Lang: typedesc[OpenLang] = Language): Lang = echo "Lan

How to make a proc with a default genetic type that can be inferred at compile time?

2021-11-05 Thread benjamindlee
I'm working on an experiment using distinct strings to represent biological sequences, which come in flavors akin to languages (which I'll use in the example below). I want to make a genetic proc that, when not supplied with a type, uses the default type. For example: type English

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread Araq
I have never liked the "import/export" idiom too much so I usually hesitate to use it. More importantly `include prelude` predates Nim's export mechanism iirc.

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread aEverr
There is no need to special case the module, you can re export modules imported (acting like an include without being an include) but for some reason prelude doesn’t do this

include std/prelude vs import std/prelude (and other small prelude oddities)

2021-11-05 Thread didlybom
I recently tried to use the prelude module for the first time, and it was not working for me. I was using "import std/prelude" instead of "include std/prelude". In hindsight it makes sense but it was not obvious to me at all. Perhaps this is clear on the documentation but I missed it. I wonder

Survey Question: flow research

2021-11-05 Thread didlybom
@ggibson, you captured perfectly my thoughts with your "ambiguous or confusing compiler errors" comment. It's not that the error messages are bad but that sometimes they require a lot of nim knowledge to understand them. This makes them not that helpful sometimes unless you really know what you

Survey Question: flow research

2021-11-05 Thread didlybom
Thank you @ynfle, I did not know about --verbosity. Unfortunately, that makes name even more verbose (duh!) so it makes the "problem" (if you can call it that) even worse. Using --hint:source is better, but it does not seem that it works in combination of --hints:off? What I'd like is to minimiz

Is something like EnTT possible with Nim?

2021-11-05 Thread didlybom
This is very cool, thanks! I’d be very cool if something like this was made into a library or even into the stdlib.