Re: Amicable numbers in Nim and a few questions
> .nims config file Thanks @Jehan, I've just finished reading up on NimScript
Re: Exploring namespaces support in Nim
@lltp This is a bit too fuzzy here for my personal preference. I don't properly get what you really want. Can you give a working example project that I can execute on my computer, best would be a git(hub) repository that I can simply clone. Then name the problem that you see in there, and give an example of how you want it to work. I have the feeling. I have the feeling, that not the language here is the problem, but the way you think about the problem. And to exclude that, I would really like to see a working example form you. > As far as I am concerned, I don't want to spend my time checking that the > names I chose conflict with nothing in the totality of packages in nimble and > elsewhere. I want to be able to rename > NativeExcelReaderPackage.open/close/write/append/metadata/etc. to > xlsread.open/close/write/append/metadata/etc. if I feel like it instead of > being stuck with it. I don't want to spend my time writing "Foo_init(); > Foo_do_bar(); Foo_do_baz()" because, after all, these are the Foo variant of > init, do_bar and do_baz... This problem simply doesn't exist, as you describe it. close/write/append/metadata/etc you can override as much as you want, because they probably have an explicitly typed first argument, it is just the open procedure, where this typed object does not exist yet. When you don't like this, you can still use init (even though you already said you would not like that). And by the way, you can always use explicit package names for function calls.
Re: messaging - or communicating between GUI's
I have written several 3D applications with GUI. Not a single time did I need multithreading for that. Of course you need to establish some communication. You could create two message queues for bidirectional communication, but I think it is overkill: var queueDirectionA: seq[Message] var queueDirectionB: seq[Message] In one GUI you read from A and write to B and in the other GUI you do the opposite. But that requires you to do design a message for whatever action you want to do. It is simple to put all the effects you want to have in a function, and just call that function directly. That would be unsafe, if you would do multithreading, but when you just have a single thread, there is nothing you need to worry. With more detail I could give more information. But right now I don't know if my feedback helps you or not.
Re: Exploring namespaces support in Nim
I'm a little disconcerted, that I cannot get your point... Exactly, why "_is clearly undefined_" or, maybe, what is meant by that. E.g.: type T1 = distinct int T2 = distinct int M = distinct int proc `*`(x, y: M): M {.borrow.} var A = 3.T1 var B = 5.T2 var C = M(A) * M(B) assert C==M(15) # that works, so ``*(x: M, y: M): M`` is defined... # further assuming ``'`` syntax exists var D = A'M * A'M assert D==T1(15) var E = A'M * B'M assert E.int==15 import typetraits echo E.type.name # ? Maybe you just mean, that a proc, taking as arguments views (`'M`) of two or more different types should be prohibited?
Re: messaging - or communicating between GUI's
> [...] any kind of sockets based package: Nim's async, nanomsg, zmq all fit. I > would likely pick nanomsg because it seems easiest to get you started [...] As the resident [anti-license-complexity](http://copyfree.org) zealot, I'd like to very highly recommend standardizing on [nanomsg](https://github.com/def-/nim-nanomsg) (MIT) over [zmq](https://en.m.wikipedia.org/wiki/ZeroMQ) (LGPL). I am promoting Nim (among its many other virtues) as the most unencumbered / lawyer-free programming language, thanks to such a large percentage of its nimble ecosystem sticking with the default MIT license. I hope this percentage will grow even higher. This makes Nim the ideal candidate to be the userland language of our future BSD-based OS projects. Any project that has any [non-copyfree](http://copyfree.org/standard/rejected) dependency isn't copyfree also. This is a big concern in the Go ecosystem, for example, where a large project with lots of dependencies typically sucks in dozens of pages of legalese that few people really fully understand...
Re: Exploring namespaces support in Nim
Hum, and what if `'M` represented a scope/namespace instead? One keeps the exact same basic type (`NDArray`) but by appending `'M`, that namespace is looked for first... This would be redundant with full names, but it would work with operators...
Re: Exploring namespaces support in Nim
> then what is type(A:T1'M*B:T2'M)? > > Regarding `A:T1'M * B:T2'M`, `*(x: M, y:M): M` is clearly undefined and > explicit casting would be necessary anyway. Well, just as I said, if the return type is undefined, then the final type is undefined and explicit casting would be necessary. (I am not saying that as if I just solved the problem...)
Re: Exploring namespaces support in Nim
**@lltp**: I've meant, if `type(A'M*A'M) == type(A)`, then what is `type(A:T1'M*B:T2'M)`?
Re: Exploring namespaces support in Nim
**@LeuGim**: in my mind, `'M` would really have been a "view" of the underlying data. If `A` or `B` cannot be represented as `M` (i.e. for now, are not a distinct type of it), then it should produce a compile error. Maybe a "Ambiguous view" just like we have ambiguous function definitions? Regarding `A:T1'M * B:T2'M`, `*(x: M, y:M): M` is clearly undefined and explicit casting would be necessary anyway. This would not really be a problem in a domain where you won't mix types that way, but the loss of generality is indeed there! There are cases where this is even more ambiguous: `A:T1'V * B:T2'V`, `*(x: V[T], y:V[T]): T` and this becomes horrible... I really like the idea of views though, but this is clearly not the way it should be handled (and I am not sure this is possible).
Re: var param vs tuple as return value
+1 Michal. The _success_ of 'Nim' is the _success_ of all of us who are interested in the learning and contributing to the language and the community !
Re: Exploring namespaces support in Nim
@lltp, regarding `'M`: That makes sense for that example, but what's for `A'M * B'M` (or `A'M * B'N`), where `A` and `B` are of different types?
Re: Exploring namespaces support in Nim
**@andrea**: More seriously, I see your point (I was not aware that these type conversion were really free, it's still leaky but better than nothing). I am going to focus on writing an actual library now, see how it turns out and what the pain points are. Then we will see how things can be improved from a code base of more than ~200 LOC
Re: Exploring namespaces support in Nim
Hum, that's interesting... I have no choice but to support your suggestion of removing `{. borrow .}` altogether since it serves no purpose: let x: MyType = newMyType() echo Mytype(f_on_original_type(OriginalType(x)))
Re: Exploring namespaces support in Nim
With current Nim (no changes needed) it would look like echo (A + NDArray(M(A) * M(A))) No runtime conversion overhead, since the types are distinct but in memory they are the same
Re: Exploring namespaces support in Nim
@LeuGim, well yes and no... AFAIK `cast[M](A)` would be of type `M` which is problematic due to type leaking: (A'M * A'M) * A # shouldn't be translated like this: cast[M](A) * cast[M](A) * A # but like this instead: cast[NDArray](cast[M](A) * cast[M](A)) * A (note that I don't care about the syntax as long as it it unobtrusive). The concept is not far from `{. borrow .}`... This is more a "I'm an NDArray but here I **act** as a Matrix" instead of "I am a NDArray but from now on, I **am** a Matrix". It is just like when you define `type myint = distinct int`: you don't expect `+` that you borrowed from `int` to return an `int` instead of `myint`. Does that make sense? @andrea: I misunderstood then, sorry
Re: Exploring namespaces support in Nim
@lltp this is exactly what I said
Re: Return SUM types from proc
Yes, I understand and agree regarding bad style. But my brain is having a hard time letting go of scala and typescript idioms (where pattern matching on return type is common). In time this problem will be fixed (I hope). Anyway, thanks for your help!
Re: Exploring namespaces support in Nim
`A'M` just meaning `cast[M](A)`?
Re: Return SUM types from proc
> Regarding pointers being the only option for polymorphic returns; I guess > this depends on the object layout used? For instance, I assume object variant > does not need to be same size but still allows polymorphism in return value, > simply by reserving space for the biggest variant in the calling stackfram. Object variants are not polymorphism (at least not in the computer science semantics of the word). But you are right, it works because it reserves the size of the largest possible variant. One obvious difference to polymorphism is that whoever defines the object type has complete control over any variants. With polymorphism, a user of your type can define a new subtype. This is why using `if v of SomeType` is bad style – you cannot know all derived types, because other code using your code may define new derived types.
Re: Exploring namespaces support in Nim
No, it is I who are sorry for not being clear enough. > So you want the from foo import type T feature to get the namespacing > benefits while at the same time you argue distinct types do not work well in > your problem domain. My use case is basically using distinct types with one or more multidimensional arrays (for the general maths) lurking underneath: so fear not! > Clashes can also be dealt with via import math except exp btw, but yes, > that's what I suggest My point was just that if I use renamed matrix functions from [here](https://docs.scipy.org/doc/scipy-0.18.1/reference/linalg.html), I would always have to write `from MatrixOps as mat import nil` anyway. But pretty much all of this seems fine now with type-specific imports. * * * Anyway, about arrays... Assume we have a general multidimensional structure with element-wise operations provided by a library. I simply need a way to say in a concise but clear way e.g. "here this operation should be handled momentarily as if X was a matrix". The solutions to that are not many: I either need to express that specificity at the procedure level (bulk renaming or full names) or at the type level ("leaky" and possibly expensive casts). But as I write it, I have an idea: what about reusing distinct type as annotations: type Tensor3D = distinct NDArray Matrix = distinct NDArray Vector = distinct NDArray M = Matrix let A: NDArray echo (A + A'M * A'M) In spite of `A` being annotated with `'M`, `A'M * A'M` would still be an NDArray...
Re: Return SUM types from proc
Ok, so object variants, which does not require allocations?, is preferred in cases like this where we simply want to return different values from a function? If yes, no need to reply Thanks
Re: Return SUM types from proc
Generally speaking, whenever you are using `if v of SomeType`, you are holding it wrong. Polymorphism gives you the power of defining dispatching methods for operations whose implementation differs based on which subtype your variable holds. If implementing your code with dispatching methods seems clumsy or simply does not fit your coding style, use object variants instead. The question of whether the values should reside on the stack or on the heap is a different one. For example, [JsonNode](http://nim-lang.org/docs/json.html#JsonNode) is an object with variants but also a `ref` type residing on the heap.
Re: Return SUM types from proc
Regarding pointers being the only option for polymorphic returns; I guess this depends on the object layout used? For instance, I assume object variant does not need to be same size but still allows polymorphism in return value, simply by reserving space for the biggest variant in the calling stackfram.
Re: Win7 installation issue
Actually, I had another problem: For nimx tests, you need nake. But I could not install it: C:\Windows\system32>nimble install nake Downloading https://github.com/fowlmouth/nake using git Warning: File inside package 'nake' is outside of permitted namespace, should be named 'nake.nim' but was named 'nakelib.nim' instead. This will be an error in the future. Hint: Rename this file to 'nake.nim', move it into a 'nake\' subdirectory, or prevent its installation by adding `skipFiles = @["nakelib.nim"]` to the .ni mble file. See https://github.com/nim-lang/nimble#libraries for more info. Verifying dependencies for nake@1.8 Warning: No nimblemeta.json file found in C:\Users\oguz\.nimble\pkgs\closure_ compiler-0.2 Warning: No nimblemeta.json file found in C:\Users\oguz\.nimble\pkgs\jsbind-0 .1 Installing nake@1.8 Building nake/nake.exe using c backend Warning: Binary 'nake.exe' was already installed from source directory. Will be overwritten. Traceback (most recent call last) nimble.nim(1073) nimble nimble.nim(999) doAction nimble.nim(608) install nimble.nim(466) installFromDir tools.nim(87)copyFileD os.nim(1290) copyFileWithPermissions os.nim(592) copyFile os.nim(153) raiseOSError Error: unhandled exception: The system cannot find the file specified. [OSError]
Re: Return SUM types from proc
References (or pointers) are a prerequisite for runtime polymorphism since they are the only way to have differently typed values fit into the same memory location, since all pointers have the same size. Might not be true for all languages.
Re: Win7 installation issue
@Araq: Overriding dll's in the bin directory with the ones you mentioned did the trick. I was able to run a nimx example, after a little bit sttrugle. I am documenting that struggle, may be it will be helpful to others: * * * I needed to install git, too. At some point I restarded cmd as administrator. Also a couple of times nimble crushed and restarting the command solved the problem. So, it seems like i was able to install nimx. I tried to run the first example in nimx web page [https://github.com/yglukhov/nimx](https://github.com/yglukhov/nimx) , but i get another error: main.nim(18, 1) Error: tabulators are not allowed Replaced tabs with spaces, and that was solved. Then it could not find sdl2.dll, which i downloaded from internet, and put to project directory, and that was also fixed. I may have restarted the compiler once or twice. At the end I saw a "Hello World" GUI program! Thanks.
Re: Return SUM types from proc
Thanks! I tried the "derived" version earlier, but with stack allocated objects, and I did not manage to get dispatch working correctly at callsite. But after changing to ref values, it works. Is ref values required to differentiate sub-types? type # If I remove ref from base, A and B # no output is printed Base = ref object of RootObj A = ref object of Base a_value: int B = ref object of Base b_value: int proc test(arg: int): Base = if arg < 0: return A(a_value: arg) else: return B(b_value: arg) let a = test(10) if a of A: echo "Got A ",A(a).a_value if a of B: echo "Got B ",B(a).b_value
Re: Return SUM types from proc
Supports, if the sum type can be treated as generic, i.e. if compiler can decide at compile-time for each use of the sum type, which concrete type will it substitute. Like in using such a proc: proc test(arg: static[int]):Ret = when arg < 0: return A(a_value:arg) else: return B(b_value:arg) But the argument, on which the type choice is made, is static, that is, compile-time: really 2 different zero-argument procs will be instantiated by compiler for `test(10)` and `test(-5)`, and their arguments should be able to be evaluated at compile-time.
Re: messaging - or communicating between GUI's
Could you paste your solution (the IPC part) for future reference?
Re: Return SUM types from proc
`A or B` needs to be collapsed to one definite type at compile time. It is typically used for parameter types where the compiler sees which type is given at the calling site. This is not applicable if you want your return values to have different types at runtime. There are multiple solutions. First solution is derived types: type Base = ref object of RootObj A = ref object of Base a_value: int B = ref object of Base b_value: int proc test(arg: int): Base = if arg < 0: return A(a_value: arg) else: return B(b_value: arg) let a = test(10) let b = test(-5) Another solution is object variants: type RetKind = enum A, B Ret = object case kind: RetKind of A: a_value: int of B: b_value: int proc test(arg: int): Ret = if arg < 0: return Ret(kind: A, a_value: arg) else: return Ret(kind: B, b_value: arg) let a = test(10) let b = test(-5)
Re: Exploring namespaces support in Nim
Sorry, but I still cannot see a consistent opinion here. So you want the `from foo import type T` feature to get the namespacing benefits while at the same time you argue distinct types do not work well in your problem domain. (Fair enough, btw, I don't disagree, a proliferation of types can be burdensome in programming.) So how would this feature help you? > Should we still blindly follow the Nim way by importing everything and > fully-qualify what clashes (in this case, almost everything math related)? Clashes can also be dealt with via `import math except exp` btw, but yes, that's what I suggest. The clashes are the problem of the _importing_ module, not of the module being imported.
Return SUM types from proc
Hi, I have a proc that needs to return many different and unrelated objects (structs) base on internal decisions. I tried model this using SUM return type (A or B). But this does not seem to work as I get a type mismatch on B path. I know I can model SUM types using object hierarchies, but the types share nothing and the syntax is a bit heavy for my simple usecase Do procs in Nim support returning SUM types? (A or B) Ex: type A = object a_value:int B = object b_value:int Ret = A or B proc test(arg:int):Ret = if arg < 0: return A(a_value:arg) else: return B(b_value:arg) let a = test(10) let b = test(-5)
Re: Error: ambiguous identifier: 'int' --use system.int or unknown.int
No, you can name it as any datatype, just the module's name becomes a symbol in the scope, the same as types or variables, so you can say write in your case `int.x`. Just there are 2 `int` then, so you have to be more explicit to use one of them, `var sum : system.int = system.int (x) + system.int (y) + system.int (z)` in your case, or `type integer=system.int`, and then use `integer` as the name for `int` type. If you really need that name for your module...
Re: Exploring namespaces support in Nim
**@Araq**: What I meant is that with proper namespace support (that is already mainly here anyway) we are not constrained to follow Matlab's lead as it's been the case in most scientific libraries (including numpy/scipy) these past few years. Matlab's way is to provide vector and matrix implementations using inconsistent names that vaguely reminds you that this is the matrix/vector variant... So already, a library creator could provide sin, exp, ^ and * in a MatrixOperators rather than the Matlabian sinm, expm, matrix_power, dot (or gemm or matmul) without worrying about any other library implementing them (the linalg submodules of numpy and scipy both contain matrix-specific operations). However, while being well-chosen names, it is understandable that they would easily clash with other packages. Now, what should happen when that occurs? * Should we tell the library creator that he was mean to choose correct but common names and that he should change them? If so, in all seriousness, we'd better strip all namespace support from Nim: it is not worth the complexity of having them if we systematically resort to the C way each time a problem occurs. * Should we suggest to better leverage the type system? Maybe... But in this case, specific types are not really a solution either: even for a simple matrix (and not higher dimensional tensors) we would have to choose whether we want element-wise, vector-specific or matrix-specific operations. Views could be a partial solution to this... Either way, this is all in the hands of the library creator eventually: namespaces are a way to bring that in our hands without asking for permission.
Re: var param vs tuple as return value
_var_ is passing-by-reference. Having return value and/or arguments passing is different issue I think. +1 @flyx
Re: Win7 installation issue
I downgraded the nimble which packaged in 0.15.2 instead in 0.16.0. After upgrading Nim to 0.16.0, I couldn't use nimble anymore so I copied the nimble.exe in 0.15.2 to my current Nim bin folder.
Re: Win7 installation issue
`[Windows: i386]` means it's 32 bits. > I assume this means nimble needs sslaeay32 or libssl32 libraries? How do I > install those? They are in `$nim\bin`, next to `nimble.exe`. I don't know why this issue keeps coming up. Do you install Nim from git or what? You can also get them here [http://nim-lang.org/download/dlls.zip](http://nim-lang.org/download/dlls.zip)
Re: Win7 installation issue
@Araq: C:\Prog\nim-0.16.0_x32\nim-0.16.0>nim -v Nim Compiler Version 0.16.0 (2017-01-08) [Windows: i386] Copyright (c) 2006-2017 by Andreas Rumpf git hash: b040f74356748653dab491e0c2796549c1db4ac3 active boot switches: -d:release I have another problem now: nimble does not work C:\Prog\nim-0.16.0_x32\nim-0.16.0>nimble install nimx could not load: (ssleay32|libssl32).dll compile with -d:nimDebugDlOpen for more information I assume this means nimble needs sslaeay32 or libssl32 libraries? How do I install those?
Re: var param vs tuple as return value
Well there's a [nim](http://stackoverflow.com/questions/tagged/nim) tag on StackOverflow. It certainly wouldn't harm if Nim had more exposure there. I think this forum should be more for discussions which do not fit into SO's Q&A format.
Re: Win7 installation issue
What does `nim -v` say? It reports the OS/CPU combination.
Re: Win7 installation issue
I ignored the finish.exe and tried to compile the first example in tutorial. The error message is below. Apparently the architecture of the nim and gcc differs. In file included from C:\tmp\nim\nim\hello\nimcache\stdlib_system.c:9:0: C:\Prog\nim-0.16.0_x64\nim-0.16.0\lib/nimbase.h:443:13: error: size of array 'Ni m_and_C_compiler_disagree_on_target_architecture' is negative typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == si zeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1]; ^~ So, instead of x64 one, i downloaded nim-0.16.0_x32.zip from [http://nim-lang.org/download.html](http://nim-lang.org/download.html) and it works now. That being said, this is confusing: I am using mingw-64, but the nim binary that works with it is nim..._x32. This brings a question: What is the architecture of the hello.exe? 32 bit? 64 bit?
Re: var param vs tuple as return value
Thank you. I will use this IRC bridge. Anyhow, I feel forum is a lot better for even newbie questions. If language becomes more popular you will have the same questions asked again and again in IRC whilst they should be easy discoverable in forum (like in stackoverflow), this could serve as additional documentation with examples.
Re: Exploring namespaces support in Nim
I observed your current issues actually to find which functions in which module/file and, by using namespaces you could immediately know where to look, is this correct? If so, in the end it would be down to lib author whether making namespace or not. imho, it shouldn't Nim's problem.
Re: Win7 installation issue
@Araq: C:\>gcc -dumpmachine i686-w64-mingw32
Re: Win7 installation issue
I didn't run the finish.exe because as the page mentioned it was optional. As long you have a working compiler in your path (gcc/cl), it would work.
Re: How to open new console window and File, FileInfo, FileHandle
@mmierzwa, for third question you can override compiler to vcc with option --cc:vcc when compiling. Or you can put it in cfg file beside your nim file, put it cc = vcc. For detailed config, check the default config file in $NIM/config/nim.cfg
Re: Win7 installation issue
I think it's a finish.exe bug because `gcc -dumpmachine` doesn't produce what it expects. What does `gcc -dumpmachine` produce?
Re: var param vs tuple as return value
There's an irc channel here [http://webchat.freenode.net/?channels=nim](http://webchat.freenode.net/?channels=nim) , which is bridged to gitter, so you don't have to sign up. It's also logged, so you can read past conversations ( logs go back to about june 2012 I think ? ) [http://irclogs.nim-lang.org](http://irclogs.nim-lang.org)
Win7 installation issue
Hi, I installed mingw-64 using mingw-builds. I moved it to standard place: C:\Prog\nim-0.16.0_x64\nim-0.16.0>where gcc c:\MinGW\bin\gcc.exe Nim's finish.exe does not like it: C:\Prog\nim-0.16.0_x64\nim-0.16.0>finish bin/nim.exe is already in your PATH [Skipping] The following *incompatible* MingW installations exist c:\MinGW\bin C:\mingw\bin No compatible MingW candidates found in the standard locations [Error] 1- What is wrong? 2- I am totally new to nim. How can i test whether my installtion is fine? Success.
Re: How to open new console window and File, FileInfo, FileHandle
> Why is this so? Moderation? Yes.
Re: var param vs tuple as return value
+1 Michal.
Re: How to open new console window and File, FileInfo, FileHandle
When I am in forum view I see there are 4 answers in this thread and I see also AironGregatti. However when I enter I see only 3 posts without that from Airon. Why is this so? Moderation?
Re: & operator to concatenate strings
@gokr and @Araq .. thanks for taking out time to share the nim language perspective.
Re: var param vs tuple as return value
Hi "Btw please join IRC or gitter instead of flooding this forum with newbie questions, no offense." I do not want to flood your forum, but I do realize my questions would be newbie as well. The problem is, if I use irc-like I have chance to get answer only from people who are already online/reading, then it is buried, while on forum it stays as separate thread. So for others possible newbie (I know there are not many newbie here, but for future?) it is easier to discover later. Maybe finding separate part of forum or something similar would be nice idea? Having said that, I am moving to gitter. Regards Michal
Re: & operator to concatenate strings
Concatenation can be considered a generic operation that works for a lot of "sequential" things, as it also is in Smalltalk for example, where the character "," is used to concatenate anything that is a "sequence of things". Since "+" has a primary mathematical meaning it's IMHO quite logical to not reuse it for concatenation too - and as Araq points out - then we can also give "+" more useful mathematical meanings for sequential types.
Re: var param vs tuple as return value
'var' can be faster since the semantics differ: Essentially a return type promises a "fresh" memory location, 'var' doesn't promise anything and so can be faster. Btw please join IRC or gitter instead of flooding this forum with newbie questions, no offense.
Re: space after inc triggers a warning during compilation
yes it is the way to write a function call. There is no lint like tool, we have the compiler for that.
Re: Error: ambiguous identifier: 'int' --use system.int or unknown.int
Ohh ... files shouldn't be named with any datatype i suppose !
Re: space after inc triggers a warning during compilation
does that mean "no space between function name 'f' and opening parenthesis (" f( ) is _the_ way to write a function call ? would you recommend a _lint_ like tool that i can run on the code to learn about these aspects of nim ?
Re: Exploring namespaces support in Nim
> With proper namespace support, this is not really a problem: I can still > calculate the element-wise exponential on a (multidimensional) array for > instance without having to prepend anything while also being able to > calculate a matrix exponential using full names... I don't understand your points at all. So which math library does it this way? Certainly not Python's most popular scientific library: [http://www.scipy-lectures.org/intro/numpy/operations.html#elementwise-operations](http://www.scipy-lectures.org/intro/numpy/operations.html#elementwise-operations) It doesn't keep element-wise ops in its own namespace or class as far as I can tell. See also [https://www.python.org/dev/peps/pep-0465](https://www.python.org/dev/peps/pep-0465)
Re: Error: ambiguous identifier: 'int' --use system.int or unknown.int
Do not name your file `int`.
Re: & operator to concatenate strings
Because of this: @[1, 2] + @[3, 4] == @[3, 6] # does not compile out of the box, but if defined, that's what it should do @[1, 2] & @[3, 4] == @[1, 2, 3, 4]
Re: space after inc triggers a warning during compilation
`f (a, b, c)` should mean "pass the tuple (a, b, c) to f", not "pass 3 args to f".
Error: ambiguous identifier: 'int' --use system.int or unknown.int
working with example on page 14 of tut1.pdf. here is the code, var x : int32 = 1.int32 var y : int8 = int8 ('a') var z : float = 2.5 var sum : int = int (x) + int (y) + int (z) echo sum on compiling the following errror is seen $ nim compile int.nim Hint: used config file '/home/strikr/source-nim/nim/config/nim.cfg' [Conf] Hint: system [Processing] Hint: int [Processing] int.nim(4, 22) Warning: a [b] will be parsed as command syntax; spacing is deprecated [Deprecated] int.nim(8, 21) Warning: a [b] will be parsed as command syntax; spacing is deprecated [Deprecated] int.nim(8, 31) Warning: a [b] will be parsed as command syntax; spacing is deprecated [Deprecated] int.nim(8, 41) Warning: a [b] will be parsed as command syntax; spacing is deprecated [Deprecated] int.nim(8, 11) Error: Error: ambiguous identifier: 'int' --use system.int or unknown.int the version of nim used is $ nim --version Nim Compiler Version 0.16.0 (2017-01-24) [Linux: amd64] Copyright (c) 2006-2017 by Andreas Rumpf git hash: 0ead17bf0ecb12e32f64c050f8d28f6c22a59adb active boot switches: -d:release what is missing in one's understanding about 'int' data type in nim ? what does the compiler mean by '\--use system.int or unknown.int' ? the compiler doesn't accept it as an option. Is this to be specified as an option ? where ?
& operator to concatenate strings
Does anybody know, why '_&_' and not '_+_' was chosen as the operator to concatenate strings ?
var param vs tuple as return value
is there any performance difference between using var parameters versus tuple as a return value ?
space after inc triggers a warning during compilation
writing an increment as inc (i) instead of inc(i) triggers a warning inc2.nim(8, 9) Warning: a [b] will be parsed as command syntax; spacing is deprecated [Deprecated] what's the reason ?
Re: Amicable numbers in Nim and a few questions
Oh my... I may need to sleep a wee bit more...