Splat operator implementation with macros

2022-12-29 Thread SolitudeSF
nsfw macro activity

Splat operator implementation with macros

2022-12-29 Thread yglukhov
Finally got around to test my idea above and here's what it looks like: import macros proc addTupleToCall(c: NimNode, t: NimNode, temps: NimNode) = let typ = getType(t) var s = t if t.kind != nnkSym: # If it's something more complex than sym, store

Splat operator implementation with macros

2022-12-20 Thread Hlaaftana
That is fixed in devel

Splat operator implementation with macros

2022-12-20 Thread ElegantBeef
Oh yay, that means we now have the best code linter.

Splat operator implementation with macros

2022-12-20 Thread ElegantBeef
Well they 'work' on typed ast. They dont even respect `{.noRewrite.}`.

Splat operator implementation with macros

2022-12-20 Thread Hlaaftana
Term rewriting macros work on checked AST IIRC

Splat operator implementation with macros

2022-12-20 Thread MichalMarsalek
Is it not possible with some term rewriting macros?

Splat operator implementation with macros

2022-12-20 Thread yglukhov
However something like this should be possible to implement: someCall() ... scalarParam ..* tupleParam # expands to someCall(scalarParam, tupleParam[0], tupleParam[1]) Run

Splat operator implementation with macros

2022-12-19 Thread Araq
Don't mistreat tuples as arrays, use arrays to begin with and the desire for a "splat" disappears.

Splat operator implementation with macros

2022-12-19 Thread ElegantBeef
You cannot use a macro inside the call statement as it does not back propagate as you'd want, there is no way of adding the expanded ast to the parent ast, it either is a `StmtList`, `Bracket` or whatever type of tree you emit, it never gets added to the call as a argument.

Splat operator implementation with macros

2022-12-19 Thread resolritter
I'd like to implement an operator `...` such that: type Point = tuple[x, y: int] let p1: Point = (2,2) let p2: Point = (3,3) echo sum(1, ...p1, ...p2) # expands to sum(1, 2, 2, 3, 3) Run Based on , which refers to