Re: Tables and Import
no, you named a module same way as another symbol, and module takes precedence. nothing to do with tables.
Re: Tables and Import
i think Image is first recognized as module. rename it to lowercase.
Re: converter with static generics not working
there is no way for generic to infer the value of N, so it cant work as a converter.
Re: Nuglifier - Nim source code uglifier
> [https://gist.github.com/Yardanico/9a2677bd8d7c5e0e869cbe451dd175cc](https://gist.github.com/Yardanico/9a2677bd8d7c5e0e869cbe451dd175cc) > gonna use that to scare people on hackernews
Re: Procedure overloading with explicit parameters
proc fac(0): int = 1 Run thats not a valid nim.
Re: More fuzz testing
what's the bug?
Re: Fuzz testing nim
compiler crashes are not expected behavior. you should report it on github.
Re: Passing a sequence by reference to a data type
var s = new seq[int] Run this should work
Re: First look
> What would be the reason for the following output? you are passing tuples
Re: Perf: Table.del(key)is taking 85% of my code's time
-d:danger -d:lto|
Re: Looking for contributions to my optimistic image library
> but a combination of poor documentation, inelegant or unstable APIs, > unresponsive developers hey, im trying
Re: Nim Cheatsheet PDF (English+Spanish+Latex)
only on windows
Re: Nim Cheatsheet PDF (English+Spanish+Latex)
thats not correct for i in 9..4: echo i # 9, 8, 7, 6, 5, 4 Run
Re: Issues with nimble paths
you need to add requires "crc32" to nimble file
Re: Return type
you can use auto return type for return type inference then use when T is string/array/whatever to separate code paths for different types.
Re: Nim version of Flask Web Framework
https://github.com/planety/prologue
Re: table of openarray as value
openarray is not a concrete type, you can use it only in procedure declarations. you need to use array or a sequence.
Re: How to write shell scripts in Nim
https://nim-lang.github.io/Nim/nimscript.html
Re: {.this: self.} pragma
yes, you need devel branch
Re: {.this: self.} pragma
https://github.com/zevv/with
Re: How to turn an instance of `T` into an instance of `ref T`?
`var refT: ref T refT[] = t ` Run
Re: Is this possible?
juan's snippet still resolves import at compiletime. nim is not python.
Re: What prevents you from using Nim as your main programming language?
oh, its another blogpost from person who just read the tutorial and never wrote more than 100 lines of nim, and never seen another nim codebase, who just needs an excuse to use rust/go/whatever. its like you dont use vscode or vim with ide features already for knowing "where the stuff comes from".
Re: Why whitespace?
>code from different sources become inconsistent. 99% of nim code i've seen >uses 2 spaces just fine. other percent is from people who use nim less than a >week. but with tabs code does become inconsistent.
Re: Suggestions for optimization?
use -d:danger if you need performance
Re: how to use Nimpretty ??
try starting with the tutorial [https://nim-lang.org/docs/tut1.html#statements-and-indentation](https://nim-lang.org/docs/tut1.html#statements-and-indentation)
Re: How to find the path to nim lib from the command-line
that doesnt work with choosenim
Re: Discord server improvements
just dont send any messages to irc from these channels? not everything should be bridged.
Re: How to chain prodecure calls that mutate a reference object ?
you are returning value, not reference. change return type to var Child
Re: Ported a Python game to Nim
thats why you should make it a proper nimble package.
Re: Ported a Python game to Nim
last-gardener/src/pattern.nim(73, 16) Error: type mismatch: got this one can be fixed by importing random, but then this error pops up. last-gardener/src/scenes.nim(104, 9) Error: attempting to call undeclared routine: 'initScene'
Re: Ported a Python game to Nim
doesn't compile. i tried fixing the errors, but each time a new pops up. you probably pushed old version or missed some file.
Re: Newbie question: Why am I getting the too many variables error on my loop index variable?
invoke items/pairs iterator explicitly
Re: Newbie question: Why am I getting the too many variables error on my loop index variable?
there is no split iterator that returns two values at a time. you're confusing it with sequence and implicit pairs. you have to keep track of the indexes on your own here.
Re: Forward declaration results in SIGSEGV?
try latest stable?
Re: Forward declaration results in SIGSEGV?
doesn't compile for me. Error: implementation of 'test.get_descriptions() [declared in test.nim(3, 6)]' expected Run whats your nim version?
Re: How to manage local dependencies with nimble?
dependencies get installed automatically when building/installing the package. [https://github.com/nim-lang/nimble#dependencies](https://github.com/nim-lang/nimble#dependencies)
Re: OK, a collection of complains
how is that related to nim/programming?
Re: OK, a collection of complains
> I will never use it to represent a student in this example. what does this even mean?
Re: A path commonPrefix function
something like that proc commonPrefix*(paths: openArray[string], sep = "/"): string = if len(paths) > 0: result = paths[0] for i in 1 .. paths.high: let path = paths[i] while not path.startsWith(result) and len(result) > 0: result.setLen(result.high) result.setLen(result.rfind(sep) + 1) Run
Re: Write Nim by using only 'v'
is this a joke to you?
Re: Macros help
varargs contruct take type and optionally a converter procedure, so you can pass differently typed arguments to varargs procedure. for templates and macros if you omit the type they are assumed as untyped parameters. careful with , and ; here.
Re: Problem with C interop/X11 bindings
nim implicitly dereferences pointers, there is no difference between these snippets.
Re: Problem with C interop/X11 bindings
there is no nil, it reports wrong size.
Re: Problem with C interop/X11 bindings
thats how bindings define that proc. and it doesn't matter in that case, its just an array index.
Problem with C interop/X11 bindings
I have two snippets, in C and Nim which _supposed_ to be exact copies of eachother. #include #include #include typedef struct keymap { int keycode_high; int keycode_low; } keymap_t; keymap_t keymap_new(Display *dpy) { keymap_t result; XDisplayKeycodes(dpy, &(result.keycode_low), &(result.keycode_high)); XkbDescPtr desc = XkbGetMap(dpy, XkbAllClientInfoMask, XkbUseCoreKbd); for (int keycode = result.keycode_low; keycode <= result.keycode_high; keycode++) { int groups = XkbKeyNumGroups(desc, keycode); printf("%d\n", groups); } XkbFreeClientMap(desc, 0, 1); return result; } int main(){ Display *dpy = XOpenDisplay(NULL); keymap_t x = keymap_new(dpy); XCloseDisplay(dpy); } Run import x11/[xlib, xkblib] import x11/xkb except X_kbGetMap type Keymap = object keycodeHigh, keycodeLow: cint proc newKeymap(display: PDisplay): Keymap = discard XDisplayKeycodes(display, addr result.keycodeLow, addr result.keycodeHigh) let desc = XkbGetMap(display, XkbAllClientInfoMask, XkbUseCoreKbd) for keycode in result.keycodeLow..result.keycodeHigh: let groups = XkbKeyNumGroups(desc, keycode.int16) echo groups XkbFreeClientMap(desc, 0, true) let display = XOpenDisplay(nil) keymap = newKeymap(display) discard XCloseDisplay display Run They are supposed to have same output, but it differs, which in nim version can lead to segfaults in further usage of returned data. I looked at structure definitions in bindings and they seem correct, so im out of ideas now.
Re: "Selector must be of an ordinal type, float or string"
but uint is... what?
Re: "Selector must be of an ordinal type, float or string"
uint64 is not an ordinal [https://nim-lang.github.io/Nim/manual.html#types-ordinal-types](https://nim-lang.github.io/Nim/manual.html#types-ordinal-types)
Re: Nim In Action worth it with 1.0
[https://www.reddit.com/r/nim/comments/df2t60/nim_in_action_worth_it_with_10](https://www.reddit.com/r/nim/comments/df2t60/nim_in_action_worth_it_with_10)/ another bot
Re: Any way to force a specific identifier name in C code?
https://nim-lang.github.io/Nim/manual.html#foreign-function-interface-exportc-pragma
Re: Nim is the friendliest language to start
> What a waste of space, I spend more time scrolling through the terminal than > actually fixing bugs. this is the most nonissue _problem_ i've heard of. almost on par with & being unreachable key.
Re: How to export custom exception types?
you didnt export extraData field.
Re: nim nimscript is not executing commands
works fine on my machine. why are you using 4 year old version of nim?
Re: Is it possible to browse the nimble.directory?
nimble search
Re: What are the compiler defaults? etc...
* you can see defaults in nim.cfg supplied with the compiler. * check styleCheck compiler option. * there is no runtime cost. * koch tools builds nimble.
Re: Help with set
what
Re: Pimp up this sub
this is a bot [https://www.reddit.com/r/nim/comments/dwv3ms/pimp_up_this_sub](https://www.reddit.com/r/nim/comments/dwv3ms/pimp_up_this_sub)/
Re: Getting fields of an object type at compile time?
https://nim-lang.github.io/Nim/iterators.html#fieldPairs.i%2CT
Re: Nim lang for beginners?
[https://narimiran.github.io/nim-basics](https://narimiran.github.io/nim-basics)/
Re: Advent of Nim 2019 megathread
badabing [https://github.com/SolitudeSF/adventOfCode](https://github.com/SolitudeSF/adventOfCode)
Re: math.sum returns as a valid an object thatt should be a RangeError
whats strange is that if you just copy the function from math to current module it will raise properly. type Probability = range[0.0..1.0] proc sum*[T](x: openArray[T]): T {.noSideEffect.} = ## Computes the sum of the elements in ``x``. ## ## If ``x`` is empty, 0 is returned. ## ## See also: ## * `prod proc <#prod,openArray[T]>`_ ## * `cumsum proc <#cumsum,openArray[T]>`_ ## * `cumsummed proc <#cumsummed,openArray[T]>`_ runnableExamples: doAssert sum([1, 2, 3, 4]) == 10 doAssert sum([-1.5, 2.7, -0.1]) == 1.1 for i in items(x): result = result + i let ps = @[Probability 0.5, 0.5, 0.5] # The following line raises properly echo "Using math sum: ", sum(ps), " typeof: ", typeof(sum(ps)) Run
Re: math.sum returns as a valid an object thatt should be a RangeError
ah, its not strange at all, math module just explicitly disables all checks {.push checks: off, line_dir: off, stack_trace: off.} Run
Re: Discord server improvements
Rule #0: Read the tutorial
Re: Archlinux updated to Nim 1.0.2
huh, at least now i know that im not pushing broken updates.
Re: Pragmas Above Procs
i know where pragmas should be, so i have 0 trouble looking for them. this is another nonissue.
Re: Pragmas Above Procs
> is a far cry from this in readability terms: it looks the same
Re: Archlinux updated to Nim 1.0.2
still has some dumbass dependency on bash and git. at least python is gone.
Re: difference between ; and , as proc parameter separator
when you're listing multiple parameters under one type like this proc test(a, b: int) Run if you're gonna use semicolon, the a parameter wont be an int. in current nim thats just useful when you're using the using statement [https://nim-lang.github.io/Nim/manual.html#statements-and-expressions-using-statement](https://nim-lang.github.io/Nim/manual.html#statements-and-expressions-using-statement) using a: string proc test(a, b: int) # a is int proc test(a; b: int) # a is string Run
Re: Add custom flags to nimble install
what is the point of customTask that is not even defined locally, if you can just add -p:-d:danger?
Re: Add custom flags to nimble install
this doesnt work
Re: Add custom flags to nimble install
why? if you need to apply configuration you should use nim.cfg or config.nims, not override default actions.
Re: It seems a bit confusing to express the current class object with the first argument.
no, one language cant look exactly like the other just because you learned it first.
Re: A taxonomy of Nim packages
i dont get the point of these categorized lists. if i need something, i search for it using existing search tools, not wander around some _curated_ list.
Re: compiling to typescript
whats the point? code produced by nim is not supposed to be read, unless for some edge case debugging.
Re: Function overloading based on object.kind
[https://github.com/alehander92/poly](https://github.com/alehander92/poly) there is a macro for that
Re: A critique of Nim
thats a cool opinion, having 0 language experience and extensively using language that does something opposite. would be nice if people instead of imagining things and speculating how they could work actually tried to use them.
Re: Equivalent of Python's sys.getsizeof
"string".len
Re: images: simple way to read/write and manipulate images in nim?
[https://github.com/SolitudeSF/imageman](https://github.com/SolitudeSF/imageman) its heavily wip but it works. if something doesnt work or functionality is missing, issue on github would be much appreciated.
Re: nim in nim
you dont have proper unicode in your console
Re: Parameter location doesn't match proc api parameter location
read the tutorial/manual. [https://nim-lang.org/docs/tut2.html#object-oriented-programming-method-call-syntax](https://nim-lang.org/docs/tut2.html#object-oriented-programming-method-call-syntax) [https://nim-lang.github.io/Nim/manual.html#lexical-analysis-identifier-equality](https://nim-lang.github.io/Nim/manual.html#lexical-analysis-identifier-equality)
Re: nimpretty binary could not be found
just compile it yourself and place its binary in PATH. its sources are included with nim.
Re: Lambdas?
[https://nim-lang.github.io/Nim/manual.html#procedures-anonymous-procs](https://nim-lang.github.io/Nim/manual.html#procedures-anonymous-procs) just omit the procedure name
Re: Nim for Beginners Video Series
no harm in bumping it
Re: [RFC] Why use Nim?
comments are even better then usual reddit/hn crowd.
Re: how to clean up Nim git repo
git clean -f
Re: Call to all nimble package authors
this idea gets a yikes from me. this is totally not gonna cause a lot of issues and unexpected side effects. no, im not salty because all my packages got sub 3 code quality.
Re: Split on whitespace except for between quotes
i made library that does maybe a bit more than you need, but it can handle this case [https://github.com/SolitudeSF/shlex](https://github.com/SolitudeSF/shlex)
Re: How to use extract string with contains a certain pattern?
this works import httpclient, xmltree, htmlparser, strtabs import nimquery var client = newHttpClient() var url = "https://www.instagram.com/p/B1oqkXKFlcD; var htmlsrc = client.getContent(url) let xml = parseHtml(htmlsrc) let elements = xml.querySelectorAll("[property='og:image']") for e in elements: echo e.attrs["content"] Run
Re: How to use extract string with contains a certain pattern?
use parseHtml from httpparser and xmltree to get tree structure that you can traverse then yourself or use something like [https://github.com/GULPF/nimquery](https://github.com/GULPF/nimquery) to find the element you need.
Re: How to write static function inside a type?????
nim is not object oriented, is doesnt have such concept.
Re: Back to Nim vs V
medvednikov is a lowtier scammer and nobody should give him attention or respect. maybe araqs remark was a bit inappropriate, but freaking out over non issue isnt helping anybody.
Re: Procs that work only inplace like strutils.removeSuffix()
i wrote macros ([https://github.com/SolitudeSF/imageman/commit/c29c13fb570785891f7b5458e2b70e69ae773d80](https://github.com/SolitudeSF/imageman/commit/c29c13fb570785891f7b5458e2b70e69ae773d80)) that generate mutating/nonmutating versions of procedures specifically for this reason
Re: What text editor are you using for Nim?
kakoune. it has some lsp capabilities with 3rd party plugin, but both the plugin and especially nimlsp are very underdeveloped.
Re: Assign string to seq[uint8]
`converter toSeqUint8(s: string): seq[uint8] = cast[seq[uint8]](s) let s: seq[uint8] = "test" doAssert s == @[116'u8, 101, 115, 116] ` Run
Re: Macro to create a dictionary (table) like in python!
{} is a sugar for array of tuples, so @ already works with it by just making a sequence. echo @{"key_1": "value_1", "key_2": "value_2"} Run results in @[("key_1", "value_1"), ("key_2", "value_2")] Run
Re: 'intVal is not accessible' error?
i can compile and run demos on latest devel with no modifications other than correct path to glu module.
Re: output order
why would it? arguments need to be evaluated first
Re: How to set toolchains for cross compilation?
To crosscompile to windows you just need to provide -d:mingw
Re: New to Nim, Made Something to Feed It
would be nice if its was a nimble project
Re: Con/IO terminal library for dummies
Nice. > Enforced prefix (con.) API isolation. yikes