Nim videos and tutorials survey

2020-10-31 Thread torarinvik
I see the difference. Does Nim have those #defines as well?

Nim videos and tutorials survey

2020-10-31 Thread torarinvik
Can't wait! Greatly appreciated!

Overriding ==

2020-10-31 Thread jackhftang
How about this? # - # this part of code does not change type TextDocument = object DrawingDocument = object SpreadsheetDocument = object proc draw(doc: TextDocument) = echo "draw text"

Module Introspection

2020-10-31 Thread disruptek
> Furthermore, plenty of languages support this kind of > introspection/reflection, and it's very useful for writing tools in those; You know what could make this argument compelling? If you actually wrote and published some Nim tools that demonstrate the need. Why should the language change fo

Module Introspection

2020-10-31 Thread cblake
> > Some more completely thought out API seems more prudent. > > So then let's wait indefinitely? That's what --experimental flags are for. I just think you would have an easier time with a more complete reflection API than just symbols (and that too should be --experimental). I don't have a sp

Passing iterators as arguments

2020-10-31 Thread KnorrFG
Wow, that looks awesome 👍

Passing iterators as arguments

2020-10-31 Thread timothee
> By wrapping them in a .closure iterator. closure iterators have limitations (no js, no vm, no nimscript, and have performance overhead) Once again, (every symbol becomes 1st class; defines 0-cost lambda and aliases; inline iterators/templates/etc

Module Introspection

2020-10-31 Thread timothee
> The ambitious and judicious folk can use parseStmt(whole file) for anything > already. that has been discussed elsewhere already, it doesn't work in many cases since you get a different (duplicate) symbol, not the original symbol; this breaks down when symbols have state (eg a threadvar insid

Overriding ==

2020-10-31 Thread sschwarzer
Thanks! The missing piece I think would be mixed containers of `Document` s. I got [this far](https://play.nim-lang.org/#ix=2CBq) , type Document = ref object of RootObj TextDocument = ref object of Document DrawingDocument = ref object of Document Spreadshe

Module Introspection

2020-10-31 Thread disruptek
And BTW, I already consider `let x = if y: return` a pretty significant weakness.

Module Introspection

2020-10-31 Thread disruptek
The idea that we "can't go up the tree" is such a fundamental assumption in the design of the language that I cannot fathom the extent of corruption weakening this spec would foment. You're talking about breaking assumptions about encapsulation and abstraction of the AST who-knows-where and who-

SSL error using httpClient

2020-10-31 Thread ggibson
I had the same issue, maybe. Github was forcefully promoting the connection to https and a certain certificate I didn't know how to handle. I needed a small statically compiled in SSL library so cobbled together an ersatz one from someone else's minimal c library. It's here on github in [one of

Module Introspection

2020-10-31 Thread cblake
Just to sharpen the conversation, the "should" question is more whether we "should make that _one thing_ easy". I suspect (but do not know) that "symbols are only the beginning". You can only tell so much from a name. People will soon after want metadata on symbols. Eg., `procs` can have many ov

Passing iterators as arguments

2020-10-31 Thread KnorrFG
I guess that makes sense. Thx

How to handle a blocking task(fswatch)?

2020-10-31 Thread geotre
I did something similar recently - I started the file watcher in a separate thread and used a channel to send relevant info back to the main thread

Help using the effects pragma

2020-10-31 Thread fxn
That's a pretty generic statement. Can you be more precise in this particular case?

Some questions regarding gc-safety, httpclient and timezones

2020-10-31 Thread graynk
Hi! I've been playing around with Nim, and to get my head around core concepts I've rewritten my existing Telegram bot in Nim. I've used [Telebot](https://github.com/ba0f3/telebot.nim) for this. The core update handler loop looks somewhat like this (abridged version): import regex

Passing iterators as arguments

2020-10-31 Thread Hlaaftana
Inline iterators are basically just an AST transformation as far as I can tell, there's no way you can translate that to a runtime behavior.

Passing iterators as arguments

2020-10-31 Thread KnorrFG
I see, thank you. I don't want to criticize nim, this is pure curiosity: coming from python it seems very strange to me to not be able to pass raw iterators around. Why was it designed like this?

Help using the effects pragma

2020-10-31 Thread Araq
The `.effects` pragma only lists exceptions and "tag" effects. import times const gigasecond = 1_000_000_000.seconds proc g() {.tags: [RootEffect].} = discard proc addGigasecond*(moment: DateTime): DateTime = result = moment + gigasecond g()

Passing iterators as arguments

2020-10-31 Thread Araq
By wrapping them in a .closure iterator. import tables, sugar type Iterable[T] = iterator: T proc iterSomething(xs: Iterable[int])= for x in xs(): echo x template toFirstClassIter(x): untyped = iterator it(): auto {.closure.} = fo

Help using the effects pragma

2020-10-31 Thread juancarlospaco
You may not always escape having side effects, that happens even on Functional-only langs.

Passing iterators as arguments

2020-10-31 Thread KnorrFG
Hey, I want to use an iterator as argument for a function. I know, that iterators cant be passed around, and they need to be wrapped in functions. However, I cant get it to work. I something like this: import tables, sugar type Iterable[T] = proc: iterator: T proc

Overriding ==

2020-10-31 Thread jackhftang
can't rely on the modifiability of the source code Run Seems Nim generic can satisfy your requirements, but I wonder how often such openness for extension is needed. type TextDocument = object DrawingDocument = object SpreadsheetDocument = object

How to handle a blocking task(fswatch)?

2020-10-31 Thread jiyinyiyong
I don't have much experience on blocking programs yet... Based on import libfswatch import libfswatch/fswatch proc callback(event: fsw_cevent, event_num: cuint) = echo event.path var mon = newMonitor()

Sublime Text user experience

2020-10-31 Thread timothee
I primarily use sublimetext (with nimlime) and disagree maintaining it is not worth it, it's one of the best editors (nim aside) and quite usable with nim thanks to nimlime, but yes it would benefit more contributors. One of its best features are being lightweight, and its plugin infrastructure

Module Introspection

2020-10-31 Thread timothee
> It's bad because depending on how it's implemented it means I cannot rename > private symbols to something else because thanks to introspection the name > could have leaked into the outside world that's easily solved by passing a param `publicOnly` and requiring an experimental flag for `publ

Get all procs in given module

2020-10-31 Thread timothee
This keeps getting asked, and is a very useful feature on which I rely in my own nim fork. I wrote a PR a while back: but it was closed without much of a debate. Maybe there is hope this PR can be re-opened so I can address whatever needs to be addre

SSL error using httpClient

2020-10-31 Thread drkameleon
Well, I think I've finally "solved" it: The error had nothing to do, neither with Nim, nor my code, or my local openssl configuration. The problem was with a particular server (I guess). I was trying to directly download a file from `raw.githubusercontent.com`...

SSL error using httpClient

2020-10-31 Thread drkameleon
I tried upgrading via Homebrew too. Now, I have: OpenSSL 1.1.1h 22 Sep 2020 Run However, it's still not working. Here's the stack trace: /usr/local/Cellar/nim/1.4.0/nim/lib/pure/httpclient.nim(1095) getContent /usr/local/Cellar/nim/1.4.0/nim/lib/pur

SSL error using httpClient

2020-10-31 Thread drkameleon
Thanks a lot for the input. Unfortunately, I just tried everything you said and it's still not working. P.S. I'm by no means an expert at SSL, so I'm a bit ... lost

SSL error using httpClient

2020-10-31 Thread mashingan
For Nim v1.4.0, the proc `net.newContext` has changed the interface with keys and certificates related files. You have to download the certificates pem files for example here: and you can do import httpclient, net let ctx = newCont

SSL error using httpClient

2020-10-31 Thread drkameleon
macOS 10.15.7 (Catalina) and LibreSSL 2.8.3

SSL error using httpClient

2020-10-31 Thread leorize
What OS are you running? And what is your OpenSSL/LibreSSL version?

SSL error using httpClient

2020-10-31 Thread drkameleon
I don't think it's `httpClient`-related, but I'm quite confused as to what this means. Basically, I'm using `httpClient` to download a file: let got = newHttpClient().getContent(url) Run and I get this: net.nim(506) raiseSSLError httpclie

Neural Networks From Scratch in Nim

2020-10-31 Thread torarinvik
Impressive stuff.

Help using the effects pragma

2020-10-31 Thread fxn
I am trying to understand why does this proc may have side-effects: import times const gigasecond = 1_000_000_000.seconds proc addGigasecond*(moment: DateTime): DateTime = moment + gigasecond Run If you change `proc` with `func` you get: