> Maybe you won't even need macros, because you can get done a lot already with
> generics and iterators on object members.
I've been poking through the nim docs a lot but haven't run into a discussion
of this approach?
[PR](https://github.com/flaviut/nim-by-example/pull/53) made!
@jlp765 I was going to do it but got stuck with work. I'll PR when I get a
minute!
It worked for me with the one change of "self" to "this", with nim 0.16.0, but
with 0.17.0 the (slighly less pleasant looking, but possibly perfectly
reasonable as I have no idea about quote) version with the extra result = that
jyapayne provided was needed.
So someone is doing a pull request to [Nim By
Example](https://github.com/flaviut/nim-by-example) to fix this, right?
It looks like there's just an issue trying to use "quote do:" in that if else
expression.
Hmm, for some reason it didn't work in the above macro. I wrongly assumed it
was removed.
> I'm not sure if this used to work because right now in Nim, you can't assign
> the result of an if ... else expression to a variable.
Of course you can, `if` is an expression in Nim (as well as in many other
languages)
You can make the oop_macro work with the following changes:
Change
result =
if exported:
# mark `typeName` with an asterisk
quote do:
type `typeName`* = ref object of `baseName`
else:
quote do:
type `typeName` = re
Also on:
[http://nim-by-example.github.io/seqs](http://nim-by-example.github.io/seqs)/
Last example on this page uses 'def' to define a procedure instead of proc!
Truth to be told, Nim is not yet Nim 1.0 and there is no 100% guarantee that
code that you write will always work in the future. But I use a lot of
metaprogramming and breaking changes are very rare. But normally when things
change, the language wants you to improve your code and changes are ver
I don't fully understand it for sure but my impression is the contents of the
big second-to-last box on this page:
> [https://nim-by-example.github.io/oop_macro](https://nim-by-example.github.io/oop_macro)/
is supposed to build, run and produce output as shown in the last box on the
page.
Inst
12 matches
Mail list logo