Re: Get a constant passed to a macro call
Well, I tried symbol.getImpl and it handles some cases but the problem is that I need to be able to dispatch a certain proc for the const's type and then apply this proc to this const, all of this at compile-time. Unluckily, symbol.getImpl doesn't allow me to do that (at least I haven't figured out how to do that).
Re: Error: cannot instantiate: 'OrderedTable'
sflennik: your code is wrong, OrderedTable can't contain different types It should be like this: from tables import OrderedTable, toOrderedTable proc getMetaInfo(filename: string, fileSize: int64): OrderedTable[string, string] = result = { "filename": filename, "size": $fileSize, }.toOrderedTable var testing = getMetaInfo("filename", 44)
Error: cannot instantiate: 'OrderedTable'
I get a compiler error for the following code. Anyone know what I am doing wrong? from tables import OrderedTable, toOrderedTable proc getMetaInfo(filename: string, fileSize: int64): OrderedTable = result = { "filename": filename, "size": fileSize, }.toOrderedTable var testing = getMetaInfo("filename", 44)
Re: Arraymancer - A n-dimensional array / tensor library
This looks like a very useful library for me. I shall certainly be checking it out. Nice one!
Re: Error: invalid indentation
Many thanks! Looks like I didn't read the manual properly, I ended up thinking that ref Parent was how inheritance works. Just for confirmation: type # This is equivalent to a struct Object1 = object # This is a reference type to the "struct" Object1 Object2 = ref Object1 # This is a class Class1 = object of RootObj # This is a child class of Class1 Class2 = ref object of Class1 # This is a reference type to Class1 Class3 = ref Class1 I have noticed RootObj is used here frequently in declaring classes - I assume that it can be substituted with any unused indentifier?
Re: Arraymancer - A n-dimensional array / tensor library
I am very excited to announce the second release of Arraymancer which includes numerous improvements `blablabla` ... Without further ado: * Communauty * There is a Gitter room! * Breaking * `shallowCopy` is now `unsafeView` and accepts `let` arguments * Element-wise multiplication is now `.*` instead of `|*|` * vector dot product is now `dot` instead of `.*` * Deprecated * All tensor initialization proc have their `Backend` parameter deprecated. * `fmap` is now `map` * `agg` and `agg_in_place` are now `fold` and nothing (too bad!) * Initial support for Cuda !!! * All linear algebra operations are supported * Slicing (read-only) is supported * Transforming a slice to a new contiguous Tensor is supported * Tensors * Introduction of `unsafe` operations that works without copy: `unsafeTranspose, unsafeReshape, unsafebroadcast, unsafeBroadcast2, unsafeContiguous` * Implicit broadcasting via `.+, .*, ./, .-` and their in-place equivalent `.+=, .-=, .*=, ./=` * Several shapeshifting operations: `squeeze`, `at` and their `unsafe` version. * New property: `size` * Exporting: `export_tensor` and `toRawSeq` * `reduce` and `reduce` on axis * Ecosystem: * I express my deep thanks to @edubart for testing Arraymancer, contributing new functions, and improving its overall performance. He built [arraymancer-demos](https://github.com/edubart/arraymancer-demos) and [arraymancer-vision](https://github.com/edubart/arraymancer-vision), check those out you can load images in Tensor and do logistic regression on those! Also thanks to the Nim communauty on IRC/Gitter, they are a tremendous help (yes Varriount, Yardanico, Zachary, Krux). I probably would have struggled a lot more without the guidance of Andrea's code for Cuda in his [neo](https://github.com/unicredit/neo) and [nimcuda](https://github.com/unicredit/nimcuda) library. And obviously Araq and Dom for Nim which is an amazing language for performance, productivity, safety and metaprogramming.
Re: Nim and hot loading - any experiences to share?
I wrote this article a while back: [https://16bpp.net/page/hot-loading-code-in-nim](https://16bpp.net/page/hot-loading-code-in-nim)
Re: Nim and hot loading - any experiences to share?
Yes, `nimrtl.dll` is in the same folder, all binaries are 32 bit, Nim version is 0.17.1. OS is 64 bit.
mathexpr, a math expression evaluator library in Nim
[https://github.com/Yardanico/nim-mathexpr](https://github.com/Yardanico/nim-mathexpr) This is a mathematic expression evaluator library in pure Nim (with no third-party dependencies). Basically it is a recursive descent evaluator. It supports many mathematical functions, also you can provide variables and add custom functions. Also it doesn't have strict rules on arguments, so all of these are valid: sqrt(max(1, 2)) sqrt(max(1 2)) sqrt max(1, 2) sqrt max(1 2) # You can even do something like this! sqrt fac log2 10 Example REPL: ## An example REPL for Mathexpr: import strutils, rdstdin, ./mathexpr, tables # Our variables (they will be available in the REPL) var ourVars = {"x": 5.0, "y": 6.0, "z": 75.0}.newTable() # Procedure should have this type: # proc(args: seq[float]): float proc mySum(args: seq[float]): float = for arg in args: result += arg # Add our custom `sum` function mathexpr.functions["sum"] = mySum while true: var expr: string try: expr = readLineFromStdin("> ") except IOError: echo "Goodbye!" quit() if expr in ["exit", "quit", "quit()", "exit()"]: quit(0) try: let result = eval(expr, ourVars) echo "$1 = $2" % [expr, $result] except: echo getCurrentExceptionMsg() continue By the way, implementation is less than 200 lines and it works in JS backend
Re: Error: invalid indentation
> Child1[T: FloatingPoint] = ref Parent1 It means that Child1 is just a reference to Parent1, so no additional fields allowed after such a declaration. I assume you intended to write something like this type floatingPoint = float | float64 | float32 Parent1Obj = object of RootObj # Parent object should be non-final Parent1 = ref Parent1Obj Parent2 = ref Parent1 Parent3 = ref Parent1 Child1[T: floatingPoint] = ref object of Parent1Obj # Child1 is a reference to object inherited from Parent1Obj nOutNodes: uint outputNodes: seq[seq[T]]
Re: Nim and hot loading - any experiences to share?
hmm, have you put the `nimrtl.dll` next to lib.dll and main.exe? have you made sure that all binaries are compiled in 32 xor 64 bit? I am using MinGW-w64 and have now added a little nim.cfg to the repo that makes sure that the compiler spits out 64 bit binaries. The Nim version I am using is 0.17.0.
Date time with millisecond output?
Is it currently possible to output date time with millisecond resolution? E.g. a date time object containing: 2017-05-29 11:08:34.768 Having looked at the [times module](https://nim-lang.org/docs/times.html), seconds seems to be the most fine grained for full dates so far. As part of a workflow, I process 10Hz GPS logs, and for various reasons full date-timestamps with ms precision are needed for each logged point (the data exists in the logs, it just needs some processing). Have I missed something in the documentation? Or is it not yet implemented, and if so, does anyone know if it will be?
Re: lambda capture in Nim
Thanks, I had missed that paragraph in the manual! So without the closureScope template the loop just generates one closure with the intances used in the last iteration and every proc that tries to make a capture actually captures that closure, is that correct? Also, it is totally unrelated, but is there a specific reason why I cannot compile the generated Javascript source with the closure compiler? It gives me an error because of an undeclared variable in a loop nimcache/jpacrepo.js:1727: ERROR - variable property is undeclared for (property in x_147603) { simply replacing "property" with "var property" seems to fix the issue (the variable 'property' seems to be used only within the scope of the for loop, it's not used as a global variable, so this should be safe to do)
Re: Nim and hot loading - any experiences to share?
I get that SIGSEGV instantly, _exit via ctrl + c_ and 1 _version 1_ been printed. I get that immediate SIGSEGV even for empty _main.nim_ and _lib.nim_.
Re: Nim and hot loading - any experiences to share?
Please share the results should you find the time to reproduce it on your machine :) [https://github.com/Serenitor/hotnim](https://github.com/Serenitor/hotnim)
Error: invalid indentation
Brand new to Nim, trying out parametric type with hierarchy, got stung with an indentation error for the last two lines that I can't figure out why type floatingPoint = float | float64 | float32 Parent1 = ref object Parent2 = ref Parent1 Parent3 = ref Parent1 Child1[T: FloatingPoint] = ref Parent1 nOutNodes: uint outputNodes: seq[seq[T]] Remedy appreciated Thanks