Re: Write Nim in Matlab/Julia style using macros while still deploy to Cloud/PC/GPU/embedded?

2020-05-22 Thread andrea
I am not sure about the current status of Arraymancer, but I believe it supports most of your requests. Neo, instead, supports only: * Slicing, concatenation, transposing... these sorts of array operations. * Broadcast basic math functions to any array. * Linear algebra (e.g. matrix

Re: How mature is async/threading in Nim?

2020-05-19 Thread andrea
> for new projects I wouldn't use anything else because the tooling is so much > better That would be great, but it requires an introduction that explains to users what ARC is, how to make use of it, how it impacts multithreading, the new sync and lent parameters, how to design collections and

I cannot understand ARC

2020-05-07 Thread andrea
I am trying to understand ARC, which seems to be promised as the future for Nim. That, in turn, redirects to [this document](https://nim-lang.org/docs/destructors.html), so I am reading that, but I cannot make head or tails of the whole document. It starts with a motivating example, which I

Re: Nim 1.2 is here

2020-04-07 Thread andrea
By the way, if Nim 1.2 requires a specific version of OpenSSL, this should be mentioned in [https://nim-lang.org/blog/2020/04/03/version-120-released.html](https://nim-lang.org/blog/2020/04/03/version-120-released.html)

Re: Nim 1.2 is here

2020-04-07 Thread andrea
Isn't OpenSSL a system library? I am not sure how to update it without breaking a lot of things. I am using MacOS Sierra, this is probably why I am having trouble

Re: Nim 1.2 is here

2020-04-06 Thread andrea
I am now getting the error could not import: X509_check_host Run every time I invoke nimble :-(

Re: Will void be unified with empty tuple?

2020-03-24 Thread andrea
There's this [https://github.com/nim-lang/Nim/issues/7370](https://github.com/nim-lang/Nim/issues/7370)

Re: Code cleanup suggestions: ctors

2020-02-25 Thread andrea
I think it would be better to give your objects ids and use those as keys to the table. Pointers, by design, can be moved

Re: private type in public API is allowed

2020-02-21 Thread andrea
There's nothing wrong in this in my opinion. It just means that `T` is an opaque type. You can get it from exported functions, and pass it to other exported functions, but you can't create one yourself or manipulate one without using one of the functions in the module that exports it. I would

Re: reader macro

2020-02-20 Thread andrea
Do you produce your AST at runtime? Because macros are run at compile time, so that's too late. It sounds like you are trying to use Nim macros like a JIT, if I understand correctly

Re: How to print output from two echo in a single line?

2020-02-12 Thread andrea
Are you sure you used write and not`writeLine`? write does exactly that, without adding newlines [https://play.nim-lang.org/#ix=2bvn](https://play.nim-lang.org/#ix=2bvn)

Re: How to print output from two echo in a single line?

2020-02-12 Thread andrea
write(stdout, someString)

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: ELI5: newruntime and arc

2020-01-16 Thread andrea
> there is no reason to despair and stop developing Nim libraries. Thank you, I ensure you that I do not despair, but I feel a little lost with all the recent changes :-)

Re: ELI5: newruntime and arc

2020-01-16 Thread andrea
The issue for me is that posts about `--gc:arc` still reference concepts like `sink` and `lent` parameters. These are described in [the post about destructors](https://github.com/nim-lang/Nim/blob/devel/doc/destructors.rst#nim-destructors-and-move-semantics), but, well, that document is not

Re: Goto based exception handling

2020-01-10 Thread andrea
How can I validate if computing 2^500 is safe without, you know, asking the computer to compute 2^500 and dealing with the overflow?

Re: How to manage local dependencies with nimble?

2020-01-10 Thread andrea
Or even when compiling - just use `nimble c` in place of `nim c` and so on. Even better, write a nimble task and call that

Re: Goto based exception handling

2020-01-10 Thread andrea
> I'm not sure what would be a reasonable way to handle an out of bounds > exceptions or an overflow even if it were catchable. It's not like a file not > found where we can expect user interaction behind. For an HTTP server, output an error 500 and go on processing other requests (the point

Re: Goto based exception handling

2020-01-09 Thread andrea
> In the "goto based exceptions" mode checked runtime errors like "Index out of > bounds" or integer overflows are not catchable and terminate the process. Hard to love the new exceptions if one cannot defensively protect against out of bounds errors and risk to see their process terminated...

Re: Nim is the friendliest language to start

2019-12-13 Thread andrea
I actually find these error messages very very helpful. Sure, sometimes they are a little verbose, but it is nice to see all existing overloads with the corresponding mismatch

Re: Practical examples showing how macros lead to better code?

2019-12-12 Thread andrea
[https://github.com/unicredit/csvtools](https://github.com/unicredit/csvtools) relies on type definitions to automatically generate a CSV parser [https://github.com/andreaferretti/memo](https://github.com/andreaferretti/memo) defines a `memoized` macro that performs memoization of a function.

Re: Disabling unused import warning locally

2019-11-08 Thread andrea
Great, thank you

Disabling unused import warning locally

2019-11-05 Thread andrea
omials, tlinear, tprimality, tintegers_modulo, tfinite_fields, tnormal_forms Run The problem is that I get a lot of warnings like /Users/andrea/progetti/emmy/tests/all.nim(16, 8) Warning: imported and not used: 'tstructures' [UnusedImport] /Users/andrea/progetti/emmy

Re: CSources are gone - How to bootstrap?

2019-10-24 Thread andrea
> They are not gone. They are frozen Good to know, I had assumed the repo was frozen because building csources was deprecated

Re: Repeated templates don't work anymore - alternatives?

2019-10-24 Thread andrea
I am wondering as well... maybe it didn't? :-D In any case, I have updated memo per @mratsim's suggestion, it seems the best approach for now

CSources are gone - How to bootstrap?

2019-10-24 Thread andrea
I used to rely on CSources to bootstrap Nim, but I just realized that [the repository](https://github.com/nim-lang/csources) has been archived. I have a custom script called [MyNim](https://gist.github.com/andreaferretti/d40af6a276fb3275d97d0f9585d8197e) to manage Nim versions, as well as

Re: Repeated templates don't work anymore - alternatives?

2019-10-24 Thread andrea
Yeah, I agree it works, and this is probably the solution I am going to take. I just don't like much the fact that I am generating a function whose name never appears anywhere, but I don't see any better solution

Re: Repeated templates don't work anymore - alternatives?

2019-10-24 Thread andrea
@cdome: the problem of using gensym is that - well, users have to be able to call this function, they could not with a generated name. @mratsim Your solution should work. It is not really optimal to generate a function with a magic name such as `resetCacheFib()` but if there are no other

Repeated templates don't work anymore - alternatives?

2019-10-24 Thread andrea
In Nim 1.0, a fix was made to disallow declaring a template of an untyped parameter more than once. That is, this is now disallowed template foo(x: untyped) = discard template foo(x: untyped) = discard Run This is correct, and one may wonder why it was

Re: Library for linear algebra

2019-09-30 Thread andrea
Hi Royi, as I have written in the README, [linear-algebra](https://github.com/unicredit/linear-algebra) is now discontinued in favor of its sequel [neo](https://github.com/unicredit/neo). But be sure to also check [ArrayMancer](https://github.com/mratsim/Arraymancer) which is much more

Re: Call to all nimble package authors

2019-09-13 Thread andrea
@bobd > There's one package, for example, that I was planning to use that gets a 2 > for code quality That's precisely my point! You are making a decision based on a cursory assessment by a person who has looked at hundreds of packages in a month. You should **not** reconsider using that

Re: Rosencrantz: a DSL to write web servers

2019-09-12 Thread andrea
I don't know, I have never mixed middleware from different libraries even using python - I always used Django, or Flask, or Bottle on their own. The existence of a basic HTTP server in the standard library can be used as a common ground on which one can develop frameworks (this is what

Re: Rosencrantz: a DSL to write web servers

2019-09-11 Thread andrea
Since handlers are nested, you should be able to see outer variables in the inner handlers. For instance something like scope do: let user = getUserData() return someHandler[ someOtherHanderl[ ok(user) ] ] Run I

Re: how to integrate existing react components in karax?

2019-08-19 Thread andrea
I published [bindings]([https://github.com/andreaferretti/react.nim](https://github.com/andreaferretti/react.nim)) to actually use React in frontend Nim applications. I can't say it is very actively maintained, but I accept PRs

Re: State of Nimble packages

2019-08-13 Thread andrea
Wow, @spip, you made a great work! As you mention, it will be complex to keep this up to date, but already having this information as of today is a great start!

Re: Fortran bindings

2019-07-17 Thread andrea
I use some Fortran bindings to the LAPACK library in [neo]([https://github.com/unicredit/neo/blob/master/neo/dense.nim#L1086)](https://github.com/unicredit/neo/blob/master/neo/dense.nim#L1086\)). Here I make use of a [fortran

Re: Nim vs V language

2019-07-02 Thread andrea
That's sad :-( But it shows the power of advertising...

Re: Nim's future: GC and the newruntime

2019-07-01 Thread andrea
@cdome It can be implemented with 100 lines of code, but can it be implemented **transparently** for users, or will GC users have to write more convoluted code than today? Moreover, can **deferred** RC be implemented with 100 lines of code (I guess not, one has to distinguish between local

Re: What prevents you from using Nim as your main programming language?

2019-06-27 Thread andrea
I see that different people really have different priorities. :-) For instance, the standard library, documentation and tooling have been really good enough for me for a long time, but I keep seeing people complain about those.

Re: What prevents you from using Nim as your main programming language?

2019-06-26 Thread andrea
> That's all there is to it, the important questions are: > Is this annoying to > use in practice? > Does it produce catastrophic crashes in practice long > after the code has been tested extensively? Agreed. > Come on, that's a terrible argument. Well, sort of. Things always evolve, but work

Re: What prevents you from using Nim as your main programming language?

2019-06-26 Thread andrea
> seem to be implying that the GC is going to be completely removed for 1.0 Sorry, I am not implying this at all. I am just saying that 1.0 will be released with a mechanism for memory management (GC) which is already in the stage of being replaced. This is bad for two reasons: * people will

Re: What prevents you from using Nim as your main programming language?

2019-06-25 Thread andrea
I have used Nim for many small experiments, but the main reason why I am not using Nim as my main programming language is that it is not popular enough. I know this is circular, but where I work I am the Nim person. If anything should go wrong on a project where Nim fails to deliver on some

Re: cannot evaluate at compile time: i

2019-06-20 Thread andrea
The fact is that `entry` is a tuple, hence the type of `entry[i]` depends on `i`: for `i < 5` it is `float`, while for `i == 6` it is `string`. The type checker, to perform its work, must be able to evaulate `i`` at compile time. If, say, ``i` was a constant, what you did would be ok. The

Re: Generic methods are deprecated?

2019-06-11 Thread andrea
> concepts were deemed to experimental yet to build another key feature on top Uh that's sad, it would have been nice to have static and runtime polymorphism coexist nicely within the same mechanism

Re: Future of Nim ?

2019-06-06 Thread andrea
> do you have any links providing examples on how to do it in Nim? I am not sure what you are asking. It is an optimization, and as such it should be invisible in frontend (i.e Nim) code. It is the task of a compiler backend to implement it, not something you do by hand. Or maybe I just

Re: Future of Nim ?

2019-06-06 Thread andrea
> even lowly shr is still in process of being changed to be more in line with > other languages (a good thing IMO) which completely broke [cello]([https://github.com/unicredit/cello](https://github.com/unicredit/cello)) :-( > the latest memory management model eliminating GC is huge and

Re: Owned refs

2019-06-04 Thread andrea
Thank you for the explanation. I am still curious, though, since it is not difficult to create a variant of the problem where one needs to actually keep a thing into two different collections. For instance, say I am designing a cache where I keep objects of type `ref T`. I want to be able to

Re: Owned refs

2019-06-03 Thread andrea
I have read the new spec, and I have one more question. With the new model, most collections in the stdlib will be written to use sink paramaters and take ownership of the objects that they contain. Many algorithms require to keep the same object in more than one collection at a time. For

Re: Owned refs

2019-05-31 Thread andrea
@cdome There is a point in discussing this now, otherwise we will end up with something unsatisfactory in 2020. The post by @GordonBGood \- while having problems with the benchmark, as pointed out by @Jehan \- discusses some shortcomings of the new runtime that are worth debating for me. The

Re: Rosencrantz is Routing DELETE Method not working?

2019-05-28 Thread andrea
Try putting explicitly rosencrantz.delete, I think there may be an issue because the function delete is overloaded

Re: Is there way to change «proc» naming?

2019-05-08 Thread andrea
> it sounds for me like proc[urrent] not like proc[essor] Actually, it is short for proc[edure]. What does procurrent even mean?

Re: Not-so-distinct types

2019-04-18 Thread andrea
Type1 and Type2 are not distinct types, they are just aliases. You are declaring a different name for the same type uint32, there is no subtyping here

Re: "Nim needs better documentation" - share your thoughts

2019-03-21 Thread andrea
https://github.com/wicast/nim-docset

Re: [some offtopic] 33 = (8866128975287528)^3+(-8778405442862239)^3+(-2736111468807040)^3

2019-03-14 Thread andrea
Well, in any case a trivial implementation will have no chance to succeed whatsoever, Nim, C or Assembly. If you want to replicate the result, you should at the very least use the methods described in the paper

Re: Immutability -- more ideas

2019-03-08 Thread andrea
Yes, please! The weird semantics for immutability is my number one issue with Nim! :-)

Re: Legal Threats In Nimble Packages

2019-03-08 Thread andrea
> Limiting the official Nimble module list to just the code with acceptable > licenses. Please. You haven't contributed a single library to Nim's ecosystem, I made 18 (including wrappers), all under Apache2. But for some reason, you keep talking as if this was a threat to the purity of Nim's

Re: Buggy concepts

2019-01-30 Thread andrea
The situation is not as dire as described, I use them quite extensively in [emmy](https://github.com/unicredit/emmy) Still, I find some issues with them, they are not completely stable right now

Re: Some nim builtin libs not doing enough error checking?

2019-01-11 Thread andrea
Well, if there is no directory, then there are no files inside it to iterate on. Makes sense to me, I would not want an exception there

Re: "Nim needs better documentation" - share your thoughts

2019-01-04 Thread andrea
I generally find Nim's documentation ok, so it is not my top priority. That said, the areas that are not well-documented are: * the various modes of GC: which one are available? how do they differ? which external requirements do they have - bohem, go libs etc. Especially, it is not clear how

Re: interesting exercise in Nim metaprogramming: Clojure-inspired data

2019-01-03 Thread andrea
I am not sure about the rationale for this design. Why don't you just export type PostalCode* = distinct string Run and then use this type elsewhere? In this way, you can leverage Nim type system. I am not really familiar with Clojure, but it looks like this design

Re: Should we get rid of style insensitivity?

2018-12-07 Thread andrea
Constraining types and variables to have different namespaces would be a solution. The only issue with that is that sometimes types can be used as values (typedesc) and in that case there could be a clash (unlikely, but still).

Re: Should we get rid of style insensitivity?

2018-12-04 Thread andrea
@preempalver It used to be the case that the first letter was also insensitive. That was changed because many people - me included - like to do something like let person: Person = ... Run

Re: Heterogen lists

2018-12-03 Thread andrea
Great if that works for you! In any case, the constraint on types comes from the fact that the only way to construct an HCons is with the cons function (because the h and t fields are private) and the only two exported overloads only allow valid constructions

Re: Heterogen lists

2018-11-30 Thread andrea
In any case, I think that in Nim a more idiomatic solutions would to use tuples instead, which are of course isomoprhic. One cannot used recursion with tuples, but that can be easily circumvented with macros.

Re: Heterogen lists

2018-11-30 Thread andrea
Uh? I just proposed a solution that implements HLists. Is there anything missing?

Re: Heterogen lists

2018-11-30 Thread andrea
Yes, since the list is heterogeneous, the type changes according to the various parameters. It is very similar to a tuple - as explained in the blog post I linked - but it behaves like a list in certain respects and this helps in writing generic procedures that would otherwise require a macro

Re: Heterogen lists

2018-11-30 Thread andrea
@alehander42 What @trtt is trying to implement is called an HList, and is a common construction in, say, Haskell or Scala. This is an [example of implementation in

Re: Heterogen lists

2018-11-30 Thread andrea
@trtt Here it is # hlist.nim type HNil* = object HCons*[H, T] = ref object h: H t: T HList = HNil or HCons let hNil* = HNil() proc cons*[H; T: HList](hd: H; tl:T): auto = HCons[H, T](h: hd, t: tl) template

Re: Heterogen lists

2018-11-29 Thread andrea
I am on my phone now, I will try to give an example tomorrow

Re: Heterogen lists

2018-11-29 Thread andrea
No, you don't need parameters there, you can leave them unspecified. HCons is just the existential type HCons[H, T] for some H and T

Re: Heterogen lists

2018-11-29 Thread andrea
If you want to prevent T to be anything other than HNil or HCons, just make the constructor private and expose two overloads of cons

Re: Heterogen lists

2018-11-29 Thread andrea
@trtt Ok, I have a version that works type HNil = object HCons*[H, T] = ref object head*: H tail*: T let hNil = HNil() proc cons*[H; T](hd: H; tl:T): auto = HCons[H, T](head: hd, tail: tl) let l = cons("hi", cons(2, hNil))

Re: Heterogen lists

2018-11-29 Thread andrea
@trtt I agree that the code I posted is not working. But I am convinced that it **should** work, and the fact that is not working is a bug of Nim. It is true that a generic T does not have fields like head and tail. On the other hand, all concrete types T which are ever used in specializing

Re: Heterogen lists

2018-11-28 Thread andrea
@trtt You can add such a constraint with `T: HList` if you want. It seems not to work very well now, maybe I will try to figure out why. But there is another point which is important. You **do not** lose the generic type information if you don't specify T. This is because the type checking and

Re: Heterogen lists

2018-11-28 Thread andrea
@trtt Apart from using solutions for pattern matching such as gara, you can iterate recursively over HLists and use if/case statements This is how I would write a barebone HList, but for some reason the recursive printAll does not seem to work type HListKind = enum hkNil,

Re: FE web libraries

2018-11-26 Thread andrea
@miran thank you, I did not think of that! :-D

Re: FE web libraries

2018-11-26 Thread andrea
What's a FE lib?

Re: Should we get rid of style insensitivity?

2018-11-23 Thread andrea
@gemath Actually, a pure Nim library could not respect NEP1 and follow a different naming style. If I use such library, I will call it using NEP1 identifiers - no importc in sight. I think it could make sense to add a warning in the compiler for the case where mixed styles are used **inside**

Re: Should we get rid of style insensitivity?

2018-11-23 Thread andrea
@allochi that experiment does not really make much sense, because you are not supposed to use style insensitivity to mix styles inside a codebase, unless you are masochistic. Style insensitivity is used to take a library written in a different style and use inside your project without having to

Re: TechEmpower Web Framework Benchmarks

2018-11-20 Thread andrea
@moerm I think the misunderstanding stems from your claims > To be frank, almost everything seems to be faster than Nim in the techempower > benchmark. > A quick look at Single query, Multiple queries, Fortunes, Data > updates (all "physical"), each with all sub-categories, showed that Nim was

Re: TechEmpower Web Framework Benchmarks

2018-11-19 Thread andrea
@moerm Nim was not in the results for these categories because - well, probably no entry for Nim was submitted :-)

Re: Should we get rid of style insensitivity?

2018-11-19 Thread andrea
Style insensitivity is my least favourite feature. That said, I also don't want a vote. I'd rather have a stable 1.0 sooner instead of another language change

Re: Nim as a hot-patching scripting language?

2018-11-06 Thread andrea
Nim does not have a REPL (well, there is one but it does not work very well), but it has an interpreter, which is used, among other things, to compile macros and to scripts Nimble. You can embed the interpreter in your application - a starting point could be

Re: should we deprecate nim.cfg in favor of config.nims format?

2018-10-23 Thread andrea
In fact, \--clang.cpp.options.linker = "-Oz -s ASM_JS=1 --separate-asm" would do as well, if not for the dots in the option name. Options without dots will be configured ina way that is almost equal to nim.cfg

Re: should we deprecate nim.cfg in favor of config.nims format?

2018-10-23 Thread andrea
I guess switch("clang.cpp.options.linker", "-Oz -s ASM_JS=1 --separate-asm") Run and so on

Re: should we deprecate nim.cfg in favor of config.nims format?

2018-10-23 Thread andrea
> Deprecation of the old config system is tough as long as the new config > system is so slow. :-( Anecdotally I have yet to experience any difference whatsoever. This may be due to the fact that I build using Nimble anyway, so the only point where I have to use config.nims/nim.cfg is to

Re: Does Nim need package-level visibility?

2018-10-10 Thread andrea
I don't know which solution I would appreciate most, but I should mention that have also frequently incurred in 1), 2), 3), 4)

Re: how to increase velocity for merging PRs?

2018-10-08 Thread andrea
It's not only about compiler, in any case: most PRs are actually for the stdlib

Re: unary operators are often best replaced by explicit names, eg: `%*` => toJson

2018-10-04 Thread andrea
If you have ever tried to write some complex JSON structure in a typed language, you will quickly realize that such shortcuts are indeed very useful. Now, this is true especially for %, which will be repeated often, while %* is only used once per structure. That said, I find %* consistent with

Re: Proc parameters, local copy

2018-10-02 Thread andrea
When you write `var a = a`, there is no local variable `a` in scope yet, so the (new) `a` gets assigned the value of the parameter `a`. When you write `var a: int`, you introduce a local variable `a` that shadows the parameter, and then `a = a` is a no-op

Re: Gara: pattern matching DSL

2018-09-26 Thread andrea
I am really happy to see a complete pattern matching library for Nim! Congratulations for your efforts!

Re: Concepts syntax and interfaces - declarative vs procedural

2018-08-08 Thread andrea
I don't think it is a good idea to be explicit about `<` being a proc. For me concepts are about (static) duck typing: if it supports `<`, then it satisfies the concept. This is good, because I will want to call `<` on members of the type. I see concepts as a promise that the code I write next

Re: Introducing the nimgen family of Nim wrappers

2018-08-08 Thread andrea
Yup, that's it

Re: Nim partners with Status.im

2018-08-07 Thread andrea
Congratulations! I am very happy to hear about this partnership with the very talented Status team!!

Re: Concepts syntax and interfaces - declarative vs procedural

2018-08-07 Thread andrea
Agreed with GULPF: the imperative syntax of concepts makes it more suited to some kind of duck typing. Moreover, I find type Comparable = concept x, y (x < y) is bool Run simpler than type Comparable[T] = concept proc `<`(x,

Re: Introducing the nimgen family of Nim wrappers

2018-08-03 Thread andrea
I have done wrappers for BLAS, LAPACK and CUDA using only c2nim and some manual work. BLAS and LAPACK are ok and they are unlikely to change, but it would be nice if my CUDA wrappers could be automated using Nimgen (ideally in a backward compatible way), so that they could be kept up to date

Re: [best practice] we should use `check` or `require` instead of `echo` + `discard` magic in tests

2018-07-31 Thread andrea
I'd say both are needed. Testament certainly works well for the compiler, but a standard library unit testing module is very useful and enough for most libraries

Re: How do I trace procs/things back to the module they come from?

2018-07-25 Thread andrea
The simplest way is to use an editor with nimsuggest support - for instance I am happy with Visual studio code and its Nim extension, but many other editors support Nim integration

Re: Globally-invoked macros

2018-07-24 Thread andrea
This discussion was rather strange until now because the first post was not visible. Now that we have more context, my impression is that the feature makes sense, but maybe it would need more use cases. recur is one, and another one I can think of is adding unobstrusive serialization support.

Re: Statistics for standard library usage

2018-05-02 Thread andrea
Agreed with what @Araq said. Mantaining a sort of enlarged standard library seems a lot of opinionated work. And this can be done externally with a small tool that just takes a list of Nimble packages and `nimble install` them all

  1   2   3   >