How can I tell Nim that a JsObject has some certain attributes?

2021-07-11 Thread ynfle
I don't think the issue is the fact that Is doesn't have that key as it's getting a type mismatch. Can you post the rest of the error message? Which part of the code is erroring?

How can I tell Nim that a JsObject has some certain attributes?

2021-07-11 Thread halloleo
In an external file I have a JavaScript function like this: function getInfo(){ return {data : "Hallo", code : 42}; } Run How can I call the object attributes/keys `data` and `code` in Nim? I tried the dot operator from jsffi: import jsffi

Nonlinear module behaviour in Nim

2021-07-11 Thread gemath
> Macros would not help here, they have a strictly local look on the AST only . > But they had to inspect different modules, they had to access the entire > environment. Well, there is `macrocache` which offers non-local AST storage, could help to at least simulate these - how do we call them,

Inlining macro and (probable) problems with HiddenStdConv/HiddenCallConv

2021-07-11 Thread Zerbina
Without the function definition available in a translation unit (c/cpp file) the C/C++ compiler simply can't inline the function there. As a rule of thumb for the C and C++ backend: In the case where the calling routine is in a different module than the callee routine, if the callee routine is

Inlining macro and (probable) problems with HiddenStdConv/HiddenCallConv

2021-07-11 Thread ElegantBeef
Well this still doesnt handle return but generalizing the replaceResult would help, since you could replace all returns with a break out of block that is at the root of the template. What Idid was simply using a template to do the heavy lifting for us, and using a macro to emit what we want. Yes

Inlining macro and (probable) problems with HiddenStdConv/HiddenCallConv

2021-07-11 Thread Yardanico
The `inline` pragma also copies the function body in each separate C file so the C compiler is more likely to inline it, but yes, it's not guaranteed

Inlining macro and (probable) problems with HiddenStdConv/HiddenCallConv

2021-07-11 Thread schneiderfelipe
As @xigoi said, there's no guarantee that a function will be inlined if annotated with the inline pragma. But even if that were the case, as far as I can tell, the inline pragma is ignored in the JS backend, so that's still useful. But yes, it's a fun exercise; I'm trying to come up with some s

Can a Heap Object Get GC'ed Even Though It's Pointed to??

2021-07-11 Thread Zerbina
In the code you posted, `appDataRef` is not a traced ref but a variable with automatic storage duration, meaning that it should live as long as it's surrounding scope.

How to make Nim more popular

2021-07-11 Thread Dan
As kotlin is to java, nim could be to c/++ and others...imagine even more simple interop with c/++ same as kotlin has with java, i think that would boost nim even more, because even today c and cpp i still in wide usage.

New concepts, visibility and mount points

2021-07-11 Thread stu002
That's a very insightful summary of the issues around Nim concepts I've been encountering. Thanks for taking the time to write it up. After experimenting with Haskell, Idris, and Rust to implement the mathematical structures I referred to, I found having typeclasses/traits/ad-hoc polymorphism c

How to make Nim more popular

2021-07-11 Thread alexeypetrushin
> Kotlin had to compete with Java. Because, If a (commercial) user wants the > Java platform, he might consider to stay within Java. So, Kotlin had to offer > smth better. Kotlin kinda already won, as it's considered by many as the "new Java". Many commercial users (project owners, dev managers

Inlining macro and (probable) problems with HiddenStdConv/HiddenCallConv

2021-07-11 Thread xigoi
IIRC, the `inline` pragma doesn't actually inline, it just puts an `inline` keyword in the generated C code, which is completely implementation-defined. Also, you may want to sometimes inline a function and sometimes not.

Can't create sequence with newSeq

2021-07-11 Thread Stefan_Salewski
All fine: type Matrix* = object numRows* : int numCol* : int data : seq[float] var m = newSeq[Matrix](3) Run

Can't create sequence with newSeq

2021-07-11 Thread Gadersd
Renaming the file to matrix.nim solved my problem. Thanks!

Can't create sequence with newSeq

2021-07-11 Thread ElegantBeef
Do you have `Matrix` declared in `Matrix.nim` if so you're refering to the module when you do `Matrix` so either rename the file to `matricies` or do `Matrix.Matrix` to access the type, the former is more idiomatic.

Can't create sequence with newSeq

2021-07-11 Thread Gadersd
I have a Matrix object defined as follows: type Matrix* = object numRows* : int numCol* : int data : seq[float] Run When I call `newSeq[Matrix](3)` I get the error "Error: expression 'Matrix' has no type (or is ambiguous)." What is

Inlining macro and (probable) problems with HiddenStdConv/HiddenCallConv

2021-07-11 Thread Stefan_Salewski
I assume that it is only a fun exercise for you, as it seems to be exactly what the Nim compiler does when we annotate a proc with the inline pragma or use a template?

How to make Nim more popular

2021-07-11 Thread Sixte
> By providing excellent integration and re-using existing platforms (compiling > to some platform is not the same as having a good integration with it). It's > hard to formulate preceicely how "good integration" should looks like. As an > example Java integration in Scala is terrible, and in Ko

Inlining macro and (probable) problems with HiddenStdConv/HiddenCallConv

2021-07-11 Thread schneiderfelipe
Hi everyone, I was doing some experimentation with macros (so much fun! 😝), namely writing a macro for inlining functions (copy-paste their bodies basically). This is what I came up with: import macros, macroutils func extendedParams(f: NimNode): NimNode = let p

How to make Nim more popular

2021-07-11 Thread Sixte
...In continuation of the post above and answering about : > break ... implicit copy forever > > The latter I'm thinking is a reference to the work being done on CPS. Can you > elaborate how that breaks the let/var distinction? I'm not super familiar > with the CPS transform, but I don't immedi

Help with object serialization please!

2021-07-11 Thread cblake
@ingo \- this is on the same machine with SQLite: import db_sqlite, times # inMem.nim const n = 1_500_000 let t0 = epochTime() let db = open(":memory:", "", "", "") # In RAM!! db.exec sql"DROP TABLE IF EXISTS bars" db.exec sql"""CREATE TABLE bars (t INTEGER PRIMAR

How to make Nim more popular

2021-07-11 Thread alexeypetrushin
There's a way to bypass this "business momentum and maturity and critical mass". The way Clojure, Kotlin, TypeScript, Elixir did it. By providing excellent integration and re-using existing platforms (compiling to some platform is not the same as having a good integration with it).

Help with object serialization please!

2021-07-11 Thread Scotpip
**UPDATED BENCHMARK** Task: read 1.5 million price bars off disk and total the volume values Platform: Win 10 Pro Workstation, 2x Xeon X5675 CPUs, 24 gigs memory, SSD @treeform approach - marshalling with flatty and supersnappy libs **Average: 0.14 secs** @cblake approach - using the memfiles

How to make Nim more popular

2021-07-11 Thread ingo
My reply was more in the light of finding a 'niche'. Most of the rest in this thread boils down to building "critical mass" and for that, stamina is required. I.m.o also of importance is what python had in the early days, a really fun community.

How to make Nim more popular

2021-07-11 Thread Scotpip
> What more does one want? As I said, as an individual the promise of performance coupled with elegant and legible code is a compelling reason to learn the language. As an organisation, not so much. I'd be more concerned with: 1. Accessing a pool of experienced developers 2. Access to exten

How to make Nim more popular

2021-07-11 Thread ingo
> [...] Nim sits nicely between the unproductive and unsafe system languages > like C & C++, and the verbose and boring GC corporate languages like C# and > Java. This is a sweet-spot [...] What more does one want?

How to make Nim more popular

2021-07-11 Thread Sixte
I'm hoping I can convince you to expand on what you mean by > Heterogeneous Environments The first question can be answered perhaps best with a video : and then the question is , how to represent it in a type system. (modelling existential types sp

How to make Nim more popular

2021-07-11 Thread shirleyquirk
I'm hoping I can convince you to expand on what you mean by > Heterogeneous Environments and how a Stackless Nim would > break ... implicit copy forever The former is well over my head, I do hope you can explain what sort of heterogeneity and uncertainty you mean The latter I'm thinking is a

How to make Nim more popular

2021-07-11 Thread Sixte
How to promote Nim? Well, where does Nim shine? * (1) Write a compiler in Nim - for Nim. This is not a pun, because * (2) Every compiler can be written in Nim, it is by far the most convenient language for that particular task. So, with advantage, a compiler for Swift could be written i

Nonlinear module behaviour in Nim

2021-07-11 Thread Sixte
> The "pragmatic workaround" would probably be "Don't export the fields, > then.", which works until there is a fourth module which actually needs > access to them... This will simply not happen because types being abstract remain abstract, they can't be opened with the underlying type or field