iterrr: extensible iterator library

2022-03-17 Thread hamidrb80
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.

iterrr: extensible iterator library

2022-03-17 Thread elcritch
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

The 'for i in ...' loop inside parsing macro

2022-03-17 Thread elcritch
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

The 'for i in ...' loop inside parsing macro

2022-03-17 Thread mardiyah
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

Simple linked list questions: Correct proc signature for first()

2022-03-17 Thread DMisener
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

Simple linked list questions: Correct proc signature for first()

2022-03-17 Thread aEverr
`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

Simple linked list questions: Correct proc signature for first()

2022-03-17 Thread DMisener
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

Cant't change the name of main html file in the output of `nim doc`?

2022-03-17 Thread monsoonman
Converting README.md to index.html is a good idea.

Cant't change the name of main html file in the output of `nim doc`?

2022-03-17 Thread monsoonman
But having an option to change the main html file in `nim doc` is a reasonable feature request. No?

How to prevent nim generate C code access parent type through `Sup` field?

2022-03-17 Thread PMunch
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?

How to prevent nim generate C code access parent type through `Sup` field?

2022-03-17 Thread sls1005
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