Re: Extract a substring

2020-02-04 Thread lovelmark
Python has no [substring](http://net-informations.com/python/basics/substring.htm) methods like substring() or substr(). Instead, we use slice syntax to get parts of existing strings. Python slicing is a computationally fast way to methodically access parts of your data. The colons (:) in

Re: Result assigned befor function completes (possibly intended behavior?)

2020-02-04 Thread Araq
It's not clear. [https://nim-lang.org/docs/manual_experimental.html#aliasing-restrictions-in-parameter-passing](https://nim-lang.org/docs/manual_experimental.html#aliasing-restrictions-in-parameter-passing) > An output parameter should never be aliased with a global or thread local > variable

Re: port psutil on mac host_statistics get nil result

2020-02-04 Thread johanberg
This coding is just very impressive. I just program on my Mac and compile but there is an issue when I try to compile it. There is an unknown error shown on my screen for my Mac called

After compiling code, Mac issue

2020-02-04 Thread johanberg
This coding is just very impressive. I just program on my Mac and compile but there is an issue when I try to compile it. There is an unknown error shown on my screen for my Mac called

Re: port psutil on mac host_statistics get nil result

2020-02-04 Thread johanberg
This coding is just very impressive. I just program on my Mac and compile but there is an issue when I try to compile it. There is an unknown error shown on my screen for my Mac called

Re: How do I extract a particular block from an external module?

2020-02-04 Thread moigagoo
Thanks! This is exactly what I was looking for. I wish there was a way to mark the thread resolved.

Re: Compile time FFI

2020-02-04 Thread jyapayne
@timothee I sent you build instructions for libffi on gitter, but here they are just for posterity: > I followed the instructions here:

Result assigned befor function completes (possibly intended behavior?)

2020-02-04 Thread mp035
Hi, I had a bug in some of my nim code and it produced some unusual behaviour. It seems that the nim compiler assigns the result of a function before the said function has completed. I managed to reproduce it: import tables var values:Table[string,string] values["item

Status status update ;) libp2p, etc

2020-02-04 Thread arnetheduck
Hey all - following up on FOSDEM, a couple of us Nim developers from Status are [hanging around](https://twitter.com/m_ratsim/status/1224769743892230151) in Brussels for the week. I figured it might be a good time to highlight some of the code we've been developing over the past few months.

Re: Unicode support for Windows 10 console

2020-02-04 Thread ktamp
I did some of my own testing using plain old C (GCC) to get more insight. * Windows 10 console really likes UTF-16 encoded text. It simply cannot get UTF-8 input. * Forcing a program to get UTF-8 input **[ _setmode(_fileno(stdin), _O_U8TEXT) ]** combined with UTF-8 code page results in NUL

Re: How do I extract a particular block from an external module?

2020-02-04 Thread mratsim
I use `let fileAST = parseStmt(slurp(file))` with file being a static string path to the file. See

Re: Hot code reloading

2020-02-04 Thread demotomohiro
I wrote a sample Hot code reloading with GLFW. I placed it on gist because I think the source code is too long to put in this forum. [https://gist.github.com/demotomohiro/64050496bb615c50fa608d7105509a53](https://gist.github.com/demotomohiro/64050496bb615c50fa608d7105509a53) It seems there are

Re: Compile time FFI

2020-02-04 Thread shashlick
When I started out with nimterop, I was forced to leverage gorgeEx and create a separate binary toast due to this exact limitation. Nimterop uses tree-sitter which is a C/C++ parsing library for a variety of programming languages so it wasn't possible to load it during compile time. Initially,

Re: Compile time FFI

2020-02-04 Thread Vindaar
I essentially had the same use case as @PMunch in the past. When I thought about implementing reading Keras stored NNs in Arraymancer, one of the problems was that 1. creating a NN in Arraymancer currently means using the DSL to design the network layout. Since that DSL generates a whole

Re: How do I extract a particular block from an external module?

2020-02-04 Thread moigagoo
The proposed solution works even without the intermediate template. If the arg type is typed then the content of the included file is passed to the macro and not the include statement. However, there's still a problem with it. If the included module contains macros, they are expanded before

Re: Compile time FFI

2020-02-04 Thread jyapayne
@timothee Thank you again for the detailed example. I see you're getting around the struct issue by passing back a pointer. It gets kind of messy, but I suppose I can deal with it :) > if you'd like to help, please tell me how I can download / build libffi on > windows... I'm not a windows

Re: Compile time FFI

2020-02-04 Thread jyapayne
@Araq > What are the use cases? What is it you need to do at compile-time that's > otherwise impossible? I would simply like to use the entire std lib at compile time. For example, sometimes it's annoying to not be able to use the regex module (although nitely's pure nim library can be used

Re: How do I extract a particular block from an external module?

2020-02-04 Thread moigagoo
Now I'm even more confused. Tried this simple code: import macros macro foo(body: untyped): untyped = echo treeRepr body foo: var x = 123 Run This won't print anything to stdout. I could swear it should print the tree representation of

Re: How do I extract a particular block from an external module?

2020-02-04 Thread moigagoo
Thanks for the tip! This won't compile unfortunately: Error: unhandled exception: 'ident' is not accessible using discriminant 'kind' of type 'TNode' [FieldError]

Re: Nimble install local package.

2020-02-04 Thread moigagoo
You don't install nimble files, you install packages. Nimble file is just meta for a package. So downloading the file alone won't do. When you've cloned the repo, you can run either nimble install` or `nimble develop in the repo folder to install the package or install in development mode

Re: How do I extract a particular block from an external module?

2020-02-04 Thread Varriount
That's actually a rather nifty use of the include statement! I can see using that for something like generating mocks and tests.

Re: Compile time FFI

2020-02-04 Thread Araq
> One thing to keep in mind is that having FFI in the VM allows it to also work > in the secret interpreter. That's a great point, but we can have a separate binary/tool for that like `nimrepl`.

Re: How do I extract a particular block from an external module?

2020-02-04 Thread solo989
Try this. import macros template tt() : untyped = include anothermodule macro t(a : typed) : untyped = echo treeRepr a t(tt()) Run

Re: Compile time FFI

2020-02-04 Thread cumulonimbus
Agree with Araq here; find a way to do it with (a possibly improved) staticExec - or alternatively, it could be solved with a bidirectional communication channel through pipes (or sockets or shared memory, though these aren't good ideas either) if Nim code with access to compiler types etc.

How do I extract a particular block from an external module?

2020-02-04 Thread moigagoo
I need to find a db block in a module and copy it entirely to a new file. So, I basically need a way to pass a module's code to a macro where I'll iterate over its nodes to find the necessary one. So far, I haven't found a way do so. Naïve attempts like this one don't work, since I'm getting

Re: Compile time FFI

2020-02-04 Thread PMunch
My biggest reason for wanting FFI at compile-time is to be able to use libraries that are wrappers around C libraries. For example for my Arduino stuff I wrote a macro that reads an image file and converts that to an array of bytes that is directly inserted into your code (this is how sprites

Re: Compile time FFI

2020-02-04 Thread andrea
One thing to keep in mind is that having FFI in the VM allows it to also work in the secret interpreter. This ensures that one can try out more things interactively, such as anything that needs `times` for instance.

Re: Can someone explain how to use the ".since" pragma?

2020-02-04 Thread mrhdias
Thanks for explaining!

Re: Nimble install local package.

2020-02-04 Thread Araq
` cd projectdir nimble develop ` Run