Warning: method has lock level , but another method has 0 [LockLevel]

2024-03-26 Thread konradmb
1. Yes, lock levels now do nothing on 2.0: 2. `--warning[LockLevel]:off` won't work, because config.nims should be a valid NimScript. You can replace it with `switch("warning","[LockLevel]:off")`. Tested, works for me. **Proper solution:** Cre

Clearer copyright license for Nim logos and assets

2023-06-18 Thread konradmb
Could you share this Polish tutorial? I'd like to see it (Polak here) :D

How to chain anonymous proc with UFCS?

2023-03-04 Thread konradmb
Thank you very much for this solution. Nim forum really needs e-mail reminders for responses. I've found about your answer only by casually looking at threads in my profile.

How to chain anonymous proc with UFCS?

2022-09-30 Thread konradmb
I mean - we already have pipe in Nim (UFCS), but with `.` What is the purpose of pipe module anyway? I guess it wasn't designed specifically for my use case?

How to chain anonymous proc with UFCS?

2022-09-30 Thread konradmb
Ok, got it. To use proc, you have to call it, duh. import sugar, pipe ["1","2","3"] |> ((it: openArray[string]) => (for i in it: echo(i)))() Run 1 2 3 Run Still looking for something stdlib only.

How to chain anonymous proc with UFCS?

2022-09-30 Thread konradmb
> What's the point of using an anonymous proc here? In this case? No point. In original case: proc regexSearch*(regex: Regex): Questions = result.add getQuestions() .filterIt(Category.B in it.categories) .filterIt( [ it.question,

How to chain anonymous proc with UFCS?

2022-09-30 Thread konradmb
import sugar, pipe discard ["1","2","3"] |> ((it: openArray[int]) => (for i in it: echo(i))) Run No output. Is it how I'm supposed to do it?

How to chain anonymous proc with UFCS?

2022-09-30 Thread konradmb
Something like this, but it doesn't compile: import sugar ["1","2","3"].((it) => for i in it: echo i) Run Background: I wanted to chain mapIt inside mapIt and since I can't change "it", I had to use map with anon proc. Then I thought - why not drop two maps and

Unescape string

2022-01-19 Thread konradmb
It won't work this way:

How to dynamically link LGPL nim library to closed-source nim application?

2022-01-19 Thread konradmb
I haven't tried it, but it seems provides a solution for case A.

Call parent `$` from overwritten converter?

2021-09-10 Thread konradmb
Thanks! It's that simple ;)

Call parent `$` from overwritten converter?

2021-09-10 Thread konradmb
I have this code: type Answer* {.pure.} = enum A, B, C, T, N converter `$`*(a: Answer): string = case a: of Answer.T: "Tak" of Answer.N: "Nie" else: $a #How to call parent? echo (A, B, T, N) Run

JSON serialization of objects containing tuples

2021-09-05 Thread konradmb
Can you post a full example? Because it's working in playground that I posted earlier.

JSON serialization of objects containing tuples

2021-09-05 Thread konradmb
Use `toJson` from `std/jsonutils`.

What's Nim's equivalent of Python's append() method for lists?

2021-08-25 Thread konradmb
It's add()

Nimview - a lightweight UI helper

2021-08-15 Thread konradmb
@marcomq Right now, there is no way to call a JS function from backend to frontend. I've read in README that you've done that intentionally, but is there a way to react to user input started from backend side? If not, would you accept a pull-request for this, if I would come up with a solution?

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread konradmb
> Looks like a bug. You should report it on GitHub Issues. Yes, @masiarek2 is right. It's not a bug. In [Nim manual](https://nim-lang.org/docs/manual.html#overloading-resolution), you can read that "If multiple routines match equally well, the ambiguity is reported during semantic analysis." Si

Accessing object in seq of parent type

2021-05-25 Thread konradmb
> it's not the way to do it. Yes, I know. The correct way would be this: type TokenKind = enum tkDigit, tkNumber Token* = ref object of RootRef case kind: TokenKind of tkDigit: valueInt: uint

Accessing object in seq of parent type

2021-05-25 Thread konradmb
> Nim does not store type information at runtime, except for inheritable > objects. So how `method` would work without it?

Accessing object in seq of parent type

2021-05-25 Thread konradmb
Yes, I've mentioned it before, thanks for code.

Accessing object in seq of parent type

2021-05-24 Thread konradmb
> Do not use cast unless you're doing Quake-fast-sqrt level stuff. I know, I'm not sure if `rType()` is possible. > The thing is, you can't make a method that returns the value of each of your > objects, because what would be the return type of such a method? That's why I'm trying to get runtim

httpclient request with host different from url

2021-05-24 Thread konradmb
Hmmm, I get only one Host header locally with netcat: POST / HTTP/1.1 Connection: Keep-Alive content-length: 20 content-type: application/json host: other-url.com user-agent: Nim httpclient/1.4.4 {"data":"some text"} Run Code:

Accessing object in seq of parent type

2021-05-24 Thread konradmb
Hmmm, somewhat yes, this would be it. type Token* = ref object of RootRef position*: int DigitToken = ref object of Token value: uint NumberToken = ref object of Token value: float var digits: seq

Accessing object in seq of parent type

2021-05-24 Thread konradmb
Yeah, sure, but sometimes you can use genericity, like in this case. I've checked how C# behaves, and it spits out runtime type (child one). This code is now more of a thought-experiment, to check if Nim is capable of patterns from OOP, than an actual use-case. I started to hate OOP because of

Accessing object in seq of parent type

2021-05-24 Thread konradmb
Oh, you're right! That's what I was missing. C# needs cast too. 😅 Ok, so, can I get the "real" runtime type of this object and cast it programmatically?

Accessing object in seq of parent type

2021-05-24 Thread konradmb
Hi, I've got this code (: type Token* = ref object of RootRef position*: int DigitToken = ref object of Token value: uint NumberToken = ref object of Token value: float var digits: seq[Token]

import unicode, strutils: ambiguous call; both unicode.strip and strutils.strip

2021-05-04 Thread konradmb
Or declare an alias to strutils's strip (or the other way). import unicode, strutils# remove this comment ! const stripStr = strutils.strip [...] alias "*" & s.stripStr.capitalizeAscii & "* ", starredWord Run

Nim website front page redesign (unofficial and WIP)

2020-08-09 Thread konradmb
Just add a new CSS rule, tune it and forget about buttons to keep those dark-siders happy 😄 [https://web.dev/prefers-color-scheme](https://web.dev/prefers-color-scheme)/ @media (prefers-color-scheme: dark) { body { color:white; background:#444 } a:link {