Re: Tables and Import

2020-06-30 Thread SolitudeSF
no, you named a module same way as another symbol, and module takes precedence. 
nothing to do with tables.


Re: Tables and Import

2020-06-30 Thread SolitudeSF
i think Image is first recognized as module. rename it to lowercase.


Re: converter with static generics not working

2020-06-28 Thread SolitudeSF
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

2020-06-27 Thread SolitudeSF
> [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

2020-06-25 Thread SolitudeSF

proc fac(0): int = 1


Run

thats not a valid nim.


Re: More fuzz testing

2020-06-22 Thread SolitudeSF
what's the bug?


Re: Fuzz testing nim

2020-06-22 Thread SolitudeSF
compiler crashes are not expected behavior. you should report it on github.


Re: Passing a sequence by reference to a data type

2020-06-21 Thread SolitudeSF

var s = new seq[int]


Run

this should work


Re: First look

2020-06-19 Thread SolitudeSF
> 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

2020-06-17 Thread SolitudeSF
-d:danger -d:lto| 


Re: Looking for contributions to my optimistic image library

2020-06-08 Thread SolitudeSF
> but a combination of poor documentation, inelegant or unstable APIs, 
> unresponsive developers

hey, im trying


Re: Nim Cheatsheet PDF (English+Spanish+Latex)

2020-05-29 Thread SolitudeSF
only on windows


Re: Nim Cheatsheet PDF (English+Spanish+Latex)

2020-05-28 Thread SolitudeSF
thats not correct 


for i in 9..4: echo i # 9, 8, 7, 6, 5, 4


Run


Re: Issues with nimble paths

2020-05-19 Thread SolitudeSF
you need to add requires "crc32" to nimble file


Re: Return type

2020-04-18 Thread SolitudeSF
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

2020-04-16 Thread SolitudeSF
https://github.com/planety/prologue


Re: table of openarray as value

2020-04-11 Thread SolitudeSF
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

2020-04-05 Thread SolitudeSF
https://nim-lang.github.io/Nim/nimscript.html


Re: {.this: self.} pragma

2020-03-25 Thread SolitudeSF
yes, you need devel branch


Re: {.this: self.} pragma

2020-03-24 Thread SolitudeSF
https://github.com/zevv/with


Re: How to turn an instance of `T` into an instance of `ref T`?

2020-02-28 Thread SolitudeSF
`var refT: ref T refT[] = t `

Run


Re: Is this possible?

2020-02-27 Thread SolitudeSF
juan's snippet still resolves import at compiletime. nim is not python.


Re: What prevents you from using Nim as your main programming language?

2020-02-25 Thread SolitudeSF
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?

2020-02-18 Thread SolitudeSF
>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?

2020-02-11 Thread SolitudeSF
use -d:danger if you need performance


Re: how to use Nimpretty ??

2020-01-31 Thread SolitudeSF
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

2020-01-24 Thread SolitudeSF
that doesnt work with choosenim


Re: Discord server improvements

2020-01-22 Thread SolitudeSF
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 ?

2020-01-19 Thread SolitudeSF
you are returning value, not reference. change return type to var Child


Re: Ported a Python game to Nim

2020-01-17 Thread SolitudeSF
thats why you should make it a proper nimble package. 


Re: Ported a Python game to Nim

2020-01-16 Thread SolitudeSF
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

2020-01-16 Thread SolitudeSF
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?

2020-01-13 Thread SolitudeSF
invoke items/pairs iterator explicitly


Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread SolitudeSF
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?

2020-01-11 Thread SolitudeSF
try latest stable?


Re: Forward declaration results in SIGSEGV?

2020-01-11 Thread SolitudeSF
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?

2020-01-10 Thread SolitudeSF
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

2020-01-08 Thread SolitudeSF
how is that related to nim/programming?


Re: OK, a collection of complains

2020-01-08 Thread SolitudeSF
> I will never use it to represent a student in this example.

what does this even mean?


Re: A path commonPrefix function

2020-01-03 Thread SolitudeSF
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'

2019-12-31 Thread SolitudeSF
is this a joke to you?


Re: Macros help

2019-12-31 Thread SolitudeSF
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

2019-12-23 Thread SolitudeSF
nim implicitly dereferences pointers, there is no difference between these 
snippets.


Re: Problem with C interop/X11 bindings

2019-12-22 Thread SolitudeSF
there is no nil, it reports wrong size. 


Re: Problem with C interop/X11 bindings

2019-12-22 Thread SolitudeSF
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

2019-12-22 Thread SolitudeSF
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"

2019-12-19 Thread SolitudeSF
but uint is... what?


Re: "Selector must be of an ordinal type, float or string"

2019-12-19 Thread SolitudeSF
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

2019-12-18 Thread SolitudeSF
[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?

2019-12-17 Thread SolitudeSF
https://nim-lang.github.io/Nim/manual.html#foreign-function-interface-exportc-pragma


Re: Nim is the friendliest language to start

2019-12-13 Thread SolitudeSF
> 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?

2019-12-09 Thread SolitudeSF
you didnt export extraData field.


Re: nim nimscript is not executing commands

2019-12-08 Thread SolitudeSF
works fine on my machine. why are you using 4 year old version of nim?


Re: Is it possible to browse the nimble.directory?

2019-12-07 Thread SolitudeSF
nimble search


Re: What are the compiler defaults? etc...

2019-12-07 Thread SolitudeSF
  * 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

2019-12-05 Thread SolitudeSF
what


Re: Pimp up this sub

2019-12-05 Thread SolitudeSF
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?

2019-12-04 Thread SolitudeSF
https://nim-lang.github.io/Nim/iterators.html#fieldPairs.i%2CT


Re: Nim lang for beginners?

2019-12-03 Thread SolitudeSF
[https://narimiran.github.io/nim-basics](https://narimiran.github.io/nim-basics)/


Re: Advent of Nim 2019 megathread

2019-12-01 Thread SolitudeSF
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

2019-11-29 Thread SolitudeSF
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

2019-11-29 Thread SolitudeSF
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

2019-11-29 Thread SolitudeSF
Rule #0: Read the tutorial


Re: Archlinux updated to Nim 1.0.2

2019-11-27 Thread SolitudeSF
huh, at least now i know that im not pushing broken updates. 


Re: Pragmas Above Procs

2019-11-27 Thread SolitudeSF
i know where pragmas should be, so i have 0 trouble looking for them. this is 
another nonissue.


Re: Pragmas Above Procs

2019-11-26 Thread SolitudeSF
> is a far cry from this in readability terms:

it looks the same


Re: Archlinux updated to Nim 1.0.2

2019-11-24 Thread SolitudeSF
still has some dumbass dependency on bash and git. at least python is gone.


Re: difference between ; and , as proc parameter separator

2019-11-17 Thread SolitudeSF
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

2019-11-14 Thread SolitudeSF
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

2019-11-14 Thread SolitudeSF
this doesnt work


Re: Add custom flags to nimble install

2019-11-14 Thread SolitudeSF
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.

2019-11-13 Thread SolitudeSF
no, one language cant look exactly like the other just because you learned it 
first.


Re: A taxonomy of Nim packages

2019-11-08 Thread SolitudeSF
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

2019-11-06 Thread SolitudeSF
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

2019-11-06 Thread SolitudeSF
[https://github.com/alehander92/poly](https://github.com/alehander92/poly) 
there is a macro for that


Re: A critique of Nim

2019-11-01 Thread SolitudeSF
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

2019-10-24 Thread SolitudeSF
"string".len


Re: images: simple way to read/write and manipulate images in nim?

2019-10-16 Thread SolitudeSF
[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

2019-10-10 Thread SolitudeSF
you dont have proper unicode in your console


Re: Parameter location doesn't match proc api parameter location

2019-10-03 Thread SolitudeSF
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

2019-10-03 Thread SolitudeSF
just compile it yourself and place its binary in PATH. its sources are included 
with nim.


Re: Lambdas?

2019-09-27 Thread SolitudeSF
[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

2019-09-26 Thread SolitudeSF
no harm in bumping it


Re: [RFC] Why use Nim?

2019-09-24 Thread SolitudeSF
comments are even better then usual reddit/hn crowd.


Re: how to clean up Nim git repo

2019-09-15 Thread SolitudeSF
git clean -f


Re: Call to all nimble package authors

2019-09-14 Thread SolitudeSF
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

2019-09-07 Thread SolitudeSF
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?

2019-09-03 Thread SolitudeSF
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?

2019-09-03 Thread SolitudeSF
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?????

2019-08-29 Thread SolitudeSF
nim is not object oriented, is doesnt have such concept.


Re: Back to Nim vs V

2019-08-22 Thread SolitudeSF
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()

2019-08-04 Thread SolitudeSF
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?

2019-08-02 Thread SolitudeSF
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]

2019-07-27 Thread SolitudeSF
`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!

2019-07-10 Thread SolitudeSF
{} 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?

2019-07-07 Thread SolitudeSF
i can compile and run demos on latest devel with no modifications other than 
correct path to glu module.


Re: output order

2019-05-16 Thread SolitudeSF
why would it? arguments need to be evaluated first


Re: How to set toolchains for cross compilation?

2019-05-14 Thread SolitudeSF
To crosscompile to windows you just need to provide -d:mingw


Re: New to Nim, Made Something to Feed It

2019-05-07 Thread SolitudeSF
would be nice if its was a nimble project


Re: Con/IO terminal library for dummies

2019-04-13 Thread SolitudeSF
Nice.

> Enforced prefix (con.) API isolation.

yikes


  1   2   >