Thanks for your suggestion.
I think something like `iterrr` or `toIterrr` is good. Any other suggestions
would be appreciated.
I plan to add `ifor` for nested loops. Something like `for*` in Racket-lang.
Nice work!
The custom ident name is going to be my new favorite syntax for that pattern. I
like how much clearer `imap[x,y](x+y)` is to read than `imap((x, y) -> x + y)`
or worse `imap(it[0] + it[1])`.
One suggestion would be to provide a non-symbol variant of your macro in
addition to `><`. S
You mixed up the variable `i` in the quote section. You only want to
interpolate (``i``) for variables created outside the quote section:
macro foo(c: char, s: string) =
result = quote do:
echo `s`
for i in `s`:
if i == `c`: echo `c`
Run
How do we have `for i in` loop inside quote do macro due to this keep on error:
macro foo(c :char; s :string) =
result = quote do:
var
i :char
echo `s`
for `i` in `s`:
if `i`==`c` : echo `c`
foo('l', "hello")
Run
`Erro
Thanks you very much. Yoy were correct on both counts. BTW: I also found
another bug. My initial version _accidently_ mutated in the source!
I finally ended up with:
proc first[T](list: var SomeLinkedList[T]): SomeLinkedNode[T] =
let node = list.head
result = node
`proc first[T](list: var SomeLinkedList[T]): SomeLinkedNode[T]`
also `result = list.head[]` must be `result = list.head`, you musnt dereference
it otherwise you get the `Obj` version which isnt the return type you list
The solution is probably painfully simple to everyone but me :-(
Just trying to model [Lisp's CAR,
CDR](https://www.gnu.org/software/emacs/manual/html_node/eintr/car-_0026-cdr.html)
functionality.
import lists
proc firstDbg(list: var SomeLinkedList) =
var node = list
Converting README.md to index.html is a good idea.
But having an option to change the main html file in `nim doc` is a reasonable
feature request. No?
Yes, and that is exactly what the `Sup` field does. I don't think there is any
way to rename that field, short of editing the compiler itself. But you might
be able to create a compatible struct and hack it with casts, but I wouldn't
recommend it. What are you trying to achieve anyways?
Maybe you need:
type
Parent {.importc, nodecl.} = object
x: cint
Child {.importc, nodecl.} = object
base: Parent
y: int
var c: Child
echo c.base.x
let p = cast[ptr Parent](addr c)
Run
11 matches
Mail list logo