Omni - DSL for low level audio programming

2020-06-24 Thread vitreo12
Hello everyone! For those who didn't attend the NimConf, I just wanted to announce here a project that I have been working on for the past 8 months, [Omni](https://vitreo12.github.io/omni). Omni is a new DSL to program audio algorithms in. It's been entirely written in Nim, leverag

Re: Name of nim file at compile time

2020-06-24 Thread vitreo12
What i mean is: I tried it and it didn't work, as it would return the module where currentSourcePath is called, and not the compiled nim file

Re: Name of nim file at compile time

2020-06-23 Thread vitreo12
I had tried it, but it will not work when used from an imported module

Re: Name of nim file at compile time

2020-06-23 Thread vitreo12
I will look into it, thanks!

Name of nim file at compile time

2020-06-23 Thread vitreo12
Hello everyone! Is there a way to retrieve the name of the .nim file that's been compiled at compile time?

Re: Define variables in proc with same name as arguments

2020-05-14 Thread vitreo12
I see, it makes sense. Thanks!

Define variables in proc with same name as arguments

2020-05-14 Thread vitreo12
Hello everyone, I was wondering if I just stumbled upon a bug here. Why does this compile and output `10`? Shouldn't it be an error to define variables with the same name of arguments to the `proc`? proc test(a : int = 0) = let a = 10 echo a test()

Re: Turn a warning into an error

2020-04-04 Thread vitreo12
Thanks! It's nice to see this implemented :)

Turn a warning into an error

2020-04-04 Thread vitreo12
Hello everyone, Is there a way of turning a compiler warning into an error? The reasoning is that I am developing some code with custom memory management (using gc:none), and I would want my code not to compile when a GcMem warning is thrown by the compiler. Thank you!

Re: Announcement: The Nim compiler is rewritten in Python with some modules optimized in C

2020-04-01 Thread vitreo12
"I think we can get away with modelling the Nim AST in C via a single void* type" This one line killed me haha

Re: DSLs and macros: custom function signature

2020-02-27 Thread vitreo12
I see your point, but I find `proc foo(args: ...): ... {.customMacro.}` to be not so user friendly compared to simply `def foo(args: ...):`. Especially considering that I am building this DSL also for teaching/learning purpose of DSP/audio algorithms, so I can expect people using it not to have

Re: DSLs and macros: custom function signature

2020-02-27 Thread vitreo12
hesis, it's still quite in its early stages, but you can find it here: [https://github.com/vitreo12/omni](https://github.com/vitreo12/omni) You can get a peek at the current syntax from the examples folder ( [https://github.com/vitreo12/omni/tree/master/omni/examples](https://github.com/vit

Re: DSLs and macros: custom function signature

2020-02-27 Thread vitreo12
I see. Well, it's kind of weird though that that specific syntax works with other symbols that are not `:`. I'm working towards an intermediate solution that creates temporary .nim files that turn `a : T = x` constructs into `a T = x` ones, and using these latter ones in the macro logic. It stil

DSLs and macros: custom function signature

2020-02-27 Thread vitreo12
Hello everyone! I am developing some DSLs using nim's macro system, and I would like to implement my own function syntax. My aim is to have the syntax to look quite similarly to Python's `def` ([https://docs.python.org/3/library/typing.html)](https://docs.python.org/3/library/typing.html\)). H

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
That's what I ended up doing, thanks.

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
Unfortunately, your approach doesn't work because most of the flags that `-d:danger` activates/deactivates are set in `nim.cfg`. In fact, if you look at the binary size of your `hi.nim` file compiled with your method and with the standard `nim c -d:danger hi.nim`, you'll see that the latter one

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
The only problem I'm finding now is that, considering that the general `nim.cfg` gets executed before `config.nims`, if I add the `-d:danger` flag to `config.nims`, it doesn't actually get applied to the resulting binary, as the behaviour for `-d:danger` is defined in `nim.cfg`. Is there a way t

Re: Add custom flags to nimble install

2019-11-14 Thread vitreo12
Because I'd simply want the user to run `nimble install` without having to provide additional flags when installing my package. This comes from the fact that the user can't use the custom flags that I provide in my nimble package before cloning the repository first. So, it's not possible to do `

Add custom flags to nimble install

2019-11-14 Thread vitreo12
Hello everyone, Is there a way to add custom compiler flags (e.g. `-d:danger`) to the `nimble install` task? I know that I can use the `--passNim` flag on the nimble call, but I was wondering if this could be directly abstracted from the user in the nimble file of my package. I tried creating m

Re: 1.0.0 is here

2019-09-23 Thread vitreo12
This is fantastic news, congratulations to the dev team. You guys are amazing.

Re: Linters in Emacs

2019-08-29 Thread vitreo12
Thank you. What I find weird, then, is that nimsuggest appears to be working just fine with other editors (like Viscose). Have you perhaps succeeded in using flymake instead? When I turn flymake-mode on, it just won't highlight any errors.

Linters in Emacs

2019-08-29 Thread vitreo12
Hello guys, I have been trying to use Emac's nim-mode ([https://github.com/nim-lang/nim-mode](https://forum.nim-lang.org/postActivity.xml#https-github-com-nim-lang-nim-mode)) and everything seems working fine, except for the linters. I am finding flycheck to be extremely buggy, and I wanted to

Re: typedesc with subtype won't compile when returning objects

2019-08-22 Thread vitreo12
Thanks for the answer. I tried your example and it indeed works, even though I would prefer the simpler syntax of `T : typedesc[SomeNumber] = typedesc[float]` to work. In any case, I also came across this other error, when trying to limit the `T` inside the `SomeObject` definition:

typedesc with subtype won't compile when returning objects

2019-08-21 Thread vitreo12
Hello everyone, I was wondering if I just found a bug or if there is something wrong with the following code: #ex1 proc test1(T : typedesc[SomeNumber] = typedesc[float]) : T = echo "type is " & $T return T(0) #works echo test1(int) #ex2

Compile C file together with Nim one

2019-08-14 Thread vitreo12
Hi everyone, I know that in Nim is possible to call C functions compiled to a shared library, but I was wondering if it could be possible to compile a C file with a set of functions directly with the Nim source, without having to compile the C file to a shared library first. If this is possible

Re: Default implementation of generic proc

2019-08-08 Thread vitreo12
I just realized that this syntax seems to compile, even if it doesn't work: proc returnZero[T = float]() : T = return T(0) Run Will this syntax work in the future? I think it is quite neat in its separation between types and values, opposed to the typedesc impl

Re: Default implementation of generic proc

2019-08-08 Thread vitreo12
To be honest, I don't particularly like the idea of a different proc name for a default state, especially if the code will be reused by others.

Re: Default implementation of generic proc

2019-08-08 Thread vitreo12
Thanks for the answer. The system.default() is a nice option, but the code I proposed was only a minimal example, in my real case I don't need to return a zero. Regarding the option you proposed, I only have the problem that I would still like to maintain the let val = returnZero[

Default implementation of generic proc

2019-08-08 Thread vitreo12
Hello everyone, I have a function that looks like this: proc returnZero[T]() : T = return T(0) Run and I would like to provide a default implementation that doesn't not require to call the T type, defaulting it to float64. The call would look like:

Re: The 'Nim way' of code structure and object composition

2019-07-30 Thread vitreo12
Thank you all for your answers. I tend to use objects more than tuples too, due to the features that @juancarlospaco highlighted. Following the discussion, what do you guys think of concepts? How would you use them to structure code? I could not find relevant documentation on those, and failed i

The 'Nim way' of code structure and object composition

2019-07-29 Thread vitreo12
Hello everyone, I hope that this question is clear enough, and that it hopefully can stimulate a healthy discussion. I have been using Nim daily for now a month, and I am still wondering about the most idiomatic way of composing objects and structure the code in Nim. I know that there is support

Re: Echo a NimNode

2019-07-28 Thread vitreo12
Thank you, it makes perfect sense.

Re: Echo a NimNode

2019-07-28 Thread vitreo12
Thanks, it worked! Shouldn't dumpTree do exactly that?

Echo a NimNode

2019-07-27 Thread vitreo12
Hello everyone, I would need to debug the NimNodes returned from getImpl Run calls, and I was looking for a function that would print out a NimNode tree structure given a NimNode, not a block of nim code. I looked at dumpTree Run , but it

Macro/Template starting with a custom character

2019-07-21 Thread vitreo12
Hello everyone, Is it possible in Nim to have a macro/template that starts with a custom character? For example, a macro like: #Declaration macro @myMacro() : ... ... #Usage @myMacro Run

Re: sizeof a ref object type

2019-07-15 Thread vitreo12
Isn't MyRefObject()[] Run allocating an unitialized instance of the type? Isn't there a way to achieve the same thing without creating an object of the type?

sizeof a ref object type

2019-07-13 Thread vitreo12
Hello guys, I was wondering how to retrieve the size of a type declared as a ref object Run Consider this example: type MyObject = object a : int b : int c : int MyRefObject = ref object

Re: Weird behaviour with generic type

2019-07-13 Thread vitreo12
Thank you all very much for the welcome and for all the help! I know see where the problem is, and I hope that, in the future, an easier syntax would work. In any case, I went with the following solution, using a generic type at the type level and specializing only in the procs' interface:

Weird behaviour with generic type

2019-07-12 Thread vitreo12
Hello everyone! I am a new Nim user (and, I have to say, I am pretty excited about this language!) coming from Julia. I was tesing some of Nim's capabilities when coming to generic types and procs, when I ran into this code not compiling: type AbstractType = int or string