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
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
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...
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
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
You mean like this thread:
[https://forum.nim-lang.org/t/3596](https://forum.nim-lang.org/t/3596)
IMO - the forum should support markdown instead of RST.
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
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).
using addr.
>
> var someObj = SomeWrapper()
>
> registerEvents(addr someObj)
>
>
> Run
why not using ref object? performance?
How do I pass the `ptr SomeWrapper` to `registerEvents`? I never used pointers
in Nim before.
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
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) =
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
Do it.
Hmm, I don't know. I'll have a look at the `typedesc` type.
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
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...
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
Twitch videos expire after a few months, so I doubt this is the case.
> 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:
21 matches
Mail list logo