Re: Using var object in a proc that is the object's property

2018-12-20 Thread 2vg
if using ref object, type Events = object onload, onfail: proc (name: string) type SomeWrapper = ref object events: Events onload, onfail: proc (name: string) proc registerEvents(wrapper: SomeWrapper) = wrapper.events.onload

Re: Future of Nim ?

2018-12-20 Thread carterza
Zig and Kit have arguably better interop capabilities with C than Nim does atm - however Nim can also interop with C++ / Obj-C and JS. Loyalty doesn't replace practicality. I've been a loyal Nim user for a couple of years now. I can't do things with Nim that I can in C++, so if I want to accomp

Re: What pattern language does the OS module use ?

2018-12-20 Thread Araq
It does. Except for the link syntax and headings. Which isn't required for the above post. The triple quotes for code examples are supported...

Re: What pattern language does the OS module use ?

2018-12-20 Thread Libman
Everyone's been whining for markdown support from day one (especially me). But that's no excuse to not click that "[Styling with RST is supported](https://forum.nim-lang.org/about/rst)" link and RTFM. And use "Preview". You can edit your comments. Place ```nim on the line before your code block

Re: Future of Nim ?

2018-12-20 Thread moerm
I'll stay away from game related stuff as I know next to nothing about game development. One thing, however, I can say (certainly not adding to my being liked around here): I personally and subjectively consider Nim's success in some game development to be a warning and a grave danger. > I do t

Re: Future of Nim ?

2018-12-20 Thread trtt
You mean like this thread: [https://forum.nim-lang.org/t/3596](https://forum.nim-lang.org/t/3596)

Re: What pattern language does the OS module use ?

2018-12-20 Thread carterza
IMO - the forum should support markdown instead of RST.

Re: Future of Nim ?

2018-12-20 Thread carterza
Right now, I can't consider Nim a competitor to C/C++ It doesn't look to replace either of these languages - at least I don't think it does. Zig for instance, has a goal to become a replacement for C - which is a very bold ambition. I do think Nim has a strong future - but I'm not sure where it

Re: Using var object in a proc that is the object's property

2018-12-20 Thread lqdev
Oh wait, it's a pointer! Mistook it as a reference (those are what I never used, I use pointers on a daily basis because of OpenGL).

Re: Using var object in a proc that is the object's property

2018-12-20 Thread 2vg
using addr. > > var someObj = SomeWrapper() > > registerEvents(addr someObj) > > > Run why not using ref object? performance?

Re: Using var object in a proc that is the object's property

2018-12-20 Thread lqdev
How do I pass the `ptr SomeWrapper` to `registerEvents`? I never used pointers in Nim before.

Re: Using var object in a proc that is the object's property

2018-12-20 Thread Araq
proc registerEvents(wrapper: ptr SomeWrapper) = wrapper.events.onload = proc (name: string) = echo "loaded " & name; wrapper[].onload(name) wrapper.events.onfail = proc (name: string) = echo "failed to load " & name; wrapper[].onfail(name) Run I'm not saying it's t

Using var object in a proc that is the object's property

2018-12-20 Thread lqdev
Hello, I'm trying to do something like this: type Events = object onload, onfail: proc (name: string) type SomeWrapper = object events: Events onload, onfail: proc (name: string) proc registerEvents(wrapper: var SomeWrapper) =

Re: Get proc arg type with templates

2018-12-20 Thread jyapayne
You should just be able to use type, no? Also, the type of the proc is the proc signature (proc (a: int): int{.noSideEffect, gcsafe, locks: 0.}). Did you want the return type? If so, you'll need a macro. import typetraits proc incr(a: int): int = a + 1 # need to rename to

Re: Functional Programming in Nim

2018-12-20 Thread juancarlospaco
Do it.

Re: Get proc arg type with templates

2018-12-20 Thread twetzel59
Hmm, I don't know. I'll have a look at the `typedesc` type.

Functional Programming in Nim

2018-12-20 Thread twetzel59
Hello all, After learning some Haskell for class I realized that the functional programming paradigm isn't completely at odds with Nim. Nim supports pure functions (so long as you don't use mutable arguments) and has a type-based effect tagging system, so it's fairly easy to track side effects

Re: What pattern language does the OS module use ?

2018-12-20 Thread itm
Note: Please overlook the irregular formatting of some lines with bold and highlights above. I struggled with RST editor, and then gave up about formatting altogether. Perhaps Nim forum needs a more newbie friendly editor, IMO...

What pattern language does the OS module use ?

2018-12-20 Thread itm
The iterators in the OS module such as walkFiles use a filename pattern as input. The OS module documentation says: iterator walkFiles(pattern: string): string Iterate over all the files that match the pattern. What sort of pattern language is used for the pattern string ? I have the follo

Re: Nim video lists

2018-12-20 Thread dom96
Twitch videos expire after a few months, so I doubt this is the case.

Re: Future of Nim ?

2018-12-20 Thread moerm
> Nim needs a "killer app". This doesn't necessarily mean a specific app, like > Rails was for Ruby - it can be a general pattern, some clear specific thing > that Nim does better than its competitors. I'm afraid neither will do. I'm afraid that "being the most libertarian programming language: