Introspection over a proc type

2022-04-26 Thread ynfle
I know that this is just an example, but what are you trying to do? The reason this doesn't work, is because the parameter passed in to the macro is a proc type, but because macros operate on ASTs it is converted to a `NimNode`. If you just want to get the return type, you wouldn't use a macro

Introspection over a proc type

2022-04-26 Thread solo989
try this import std/[macros, strformat, strutils] func f(x: int): seq[string] = discard proc getReturnType(x: NimNode): NimNode = x.getimpl.params[0] macro doStuffWithReturnType(x: proc): untyped = let rT = getReturnType(x)

Optimize parsing large file line-by-line

2022-04-26 Thread cblake
@PMunch \- my hunch about bioinformatics was right. A test file I was using is called "1kg_phase1_all.bim" which is widely distributed. I got mine out of [here](https://www.dropbox.com/s/k9ptc4kep9hmvz5/1kg_phase1_all.tar.gz?dl=1) but I think this file is widely distributed as "1kg_phase1_all"

Brogrammer uptick

2022-04-26 Thread Yardanico
You probably scraped the IRC logs, so if anyone else wants to do similar analysis without having to scrape all messages, I've prepared a new IRC message dump (previous one was from a year ago) - . It's not 100% accurate and might have

Introspection over a proc type

2022-04-26 Thread ynfle
If you post more information, I'd be happy to help you out

Introspection over a proc type

2022-04-26 Thread krakengore
At this time i'm just experimenting. This is what i'm trying to do, more or less: import std/[macros, strformat, strutils] func f(x: int): seq[string] = discard macro getReturnType(x: proc): untyped = x.getimpl.params[0] macro

Brogrammer uptick

2022-04-26 Thread dom96
Wow, very cool visualisation. How did you create it? Can you share any scripts you've used? Really interesting to see the late-EU-time majority diminish into flatness. It is interesting that 2020 has so much more activity, my guess is it's due to 1.0 being released but it was released late

Introspection over a proc type

2022-04-26 Thread krakengore
Ideally i would like to initialise it inside the macro to do some computation for manipulate the returned ast, not return the type itself. Much like moving your let instruction inside getReturnType

Introspection over a proc type

2022-04-26 Thread ynfle
A macro is code manipulation tool, you can't return a variable initialized inside the macro. What you can do is generate the AST that will initialize a variable. Is this what you wanted? import std/[macros, strformat, strutils] func f(x: int): seq[string] = discard

Introspection over a proc type

2022-04-26 Thread krakengore
If i pass a type to a macro, i would like to instantiate a local variable of that type inside the macro. like if i get the return type of the passed proc, i would like to declare a var of that type inside the macro body to do computations (not just generate nim nodes).

Brogrammer uptick

2022-04-26 Thread geotre
Well, you nerdsniped me... full link [here](https://nim-lang.org) Looks like there is a bit of a trend. Also interesting to see the massively increased activity in 2020. (Note this is pretty basic, it includes all entries from the irc logs including user connect/disconnect etc, so numbers are

Introspection over a proc type

2022-04-26 Thread ynfle
I'm not sure what are you trying to do. What is the seq with a string in is supposed to be? A type? You also redeclared x. What are you trying to accomplish?

Brogrammer uptick

2022-04-26 Thread PMunch
Hmm interesting, it used to be more active during European day hours. But I guess we might have attracted a bigger American following. Someone should graph out IRC logs to see activity..

My nooby questions on nim-web3 library

2022-04-26 Thread Cnerd
Hello , I plan on executing a personal project and I need some information before I start. I have googling for over a week now and some of my questions are still left unanswered that's why I want to ask folks on this forum, any contribution is very much appreciated. Here are my questions *

Brogrammer uptick

2022-04-26 Thread Zoom
> bruh Shouldn't we expect you use "bruv" by now? @PMunch, I've already mentioned it in the Matrix/IRC, but from my observations, the chat room is considerably more active during the night time in Europe, while you'd expect the opposite if the majority of Nim users was from there. So,

C++ binding variadic template

2022-04-26 Thread krakengore
The nearest thing i could achieve is this: import macros {.emit: """/*TYPESECTION*/ #include #include template struct TTuple : std::tuple { }; """.} type TTuple1[T] {.importcpp:"TTuple<'*0>".} = object

Introspection over a proc type

2022-04-26 Thread krakengore
Yeah i see, but then any passed type inside a macro is not possible to "materialize" it. import std/macros func f(x: int): seq[string] = discard macro getReturnType(x: proc): untyped = var x : x.getimpl.params[0] = @["doesn't"] result

Introspection over a proc type

2022-04-26 Thread ynfle
It doesn't return a NimNode, it does a code replacement (that's what macros do) of the return type of the proc. That can be demonstrated with the following code import std/macros func f(x: int): seq[string] = discard macro getReturnType(x: proc): untyped =

Introspection over a proc type

2022-04-26 Thread krakengore
This will return a NimNode, i was trying to have getReturnType to return the `typedesc` instead

Brogrammer uptick

2022-04-26 Thread PMunch
Might be that Nim is starting to become more used in America. The Nim userbase has historically shifted quite heavily towards Europe, but some Asian and American users. The Asian userbase has increased quite a bit, but we don't see them much around here, probably because of language barriers.