Re: Any photos or videos from NIM @FOSDEM ?
Check out our Twitter: [https://twitter.com/nim_lang](https://twitter.com/nim_lang)
Any photos or videos from NIM @FOSDEM ?
(NT)
Re: Base Class Methods
You are right, i forgot to add the type casting. The less verbose version is to define a base proc and put there any common code for toolMethod: type A = ref object of RootRef i: int B = ref object of A c: char proc baseTest(a: A) = a.i = 1 method test(a: A) {.base.} = baseTest(a) method test(b: B) = baseTest(b) b.c = '1' let b = B() test(b) echo b[]
Re: A few issues
@Araq 1. Thank you. 2. You're right. My aging eyes did not see the ':'. 3. See the Tutorial: [https://nim-lang.org/docs/tut1.html#basic-types](https://nim-lang.org/docs/tut1.html#basic-types) . 'String' is among them.
Re: asyncdispatch and "closing server socket"
@Araq I think my example didn't clearly show that the issue was that the decision to close the server socket happens "independently" from the code that accepts incoming connections. I've now move the "close code" in the same proc as the "open code" (as you suggested), and use regular polling on a volatile flag to tell the proc to terminate. I don't remeber seeing that last "{.gcsafe.}:" syntax before. I think that might solve some of my problems.
Re: asyncdispatch and "closing server socket"
In your snippet you don't have to split up this in 2 different procs. And even if you do, you can pass `server` as a parameter. > And, more generally, does that mean I still need to use shared-heap to pass > messages/signals across async tasks? I think you can also use (async) queues instead. > Is there a way to say "run this async task in the same thread as that other > async task"? Yes, you can access the global in a section like proc foo = ... {.gcsafe.}: myglobal.add(stuff)
Re: A few issues
Useful trick 1\. open main module doc: [https://nim-lang.org/docs/system.html](https://nim-lang.org/docs/system.html) 2\. Do "group by type" 3\. Find cstring type You will learn most of the stuff cstring can do
Re: Base Class Methods
Thanks for the responses guys. Araq: Thanks. Sorry, I had proc in my example but I meant method. I basically want to have a common set of methods that can be shared among my child types and want to know some good ways to achieve this in nim. Ar: Thanks for the suggestion. That works although I still end up having to cast it as a tool - not really a problem, I was just hoping there was a way to avoid casting / be less verbose. I am interested in knowing how to do this in a nim, non-OOP way.
Re: Very impressed so far
Welcome to nim-land. Go and Rust are common stops for new users as far as I read.
Re: Base Class Methods
You can use [procCall](https://nim-lang.org/docs/system.html#procCall,untyped): procCall toolMethod(gun, 5) Bear in mind nim is not as OOP friendly as other popular languages such as Java/C#. Here you are not expected to use inheritance for everything. By the way: [https://github.com/nim-lang/Nim/issues/4329](https://github.com/nim-lang/Nim/issues/4329)
Re: Moving
var myPendingRequests {.threadvar.}: HashSet[ptr MsgBase] myPendingRequests.init() The compiler made you write this, it disallows `var myPendingRequests {.threadvar.} = initSet[ptr MsgBase]()`. Ever wondered why? Because it would only run for the main thread. I improved its error message in the hope it clears things up.
Re: Moving
> If the error goes away, then that will "prove" the HashSet (and presumably > every other complex threadvar object) needs to be initialised explicitly in > each thread. If that is the case, it would be nice to have some syntax > (something like the opposite of "static:") that takes care of that for you. Yeah, that's how thread local storage works, every thread needs to initialize its very own memory. We had something like you propose called `onThreadCreation` but it just encourages races and so we removed it again.
Re: Base Class Methods
Use `method` instead of `proc`? Not sure I understand your question.
Re: A few issues
1. [https://github.com/nim-lang/nim/issues](https://github.com/nim-lang/nim/issues) 2. No, it doesn't, it shows the correct syntax `-d:release`. 3. Fair enough, but I doubt `string` is a "basic type".
Re: Can't send email via port 587 with TLS
When you use SSL, you need to specify this parameter when compiling: nim c -d:SSL xx.nim
Re: Is there any Textadept user here ?
My version is 9.6. ui.set_theme() is the good function for me (and not set_theme()), so it seems "ui" is also a buffer. The concept of buffer remains mysterious for me, but Textadept is usable now.