Re: color text output in nimble

2018-08-01 Thread Araq
As I said, Nimscript doesn't support `terminal.nim` (on Windows, maybe on Posix it works).

Re: --stdout question

2018-08-02 Thread Araq
No, it's just about whether error messages go to `stderr` or `stdout`. Pure nonsense.

Re: should we rename git branch `devel` to `master` and `master` to `stable`?

2018-07-30 Thread Araq
I'm not a git expert, but I'm in great favor of your suggestion. We can make `devel` an alias for `master` for a transition period afaik.

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

2018-07-30 Thread Araq
I don't like `unittest.nim` at all. For all sorts of reasons, historically, unittest would trigger compiler bugs that the test itself wouldn't. `unittest`'s implementation is far too messy and tests should be simple. Tests that are run by Nim's "testament" tool should use `doAssert` instead.

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

2018-07-31 Thread Araq
Unittesting is not good enough for Nim, we also have tests that check the compiler outputs warnings/errors etc. How are you gonna "unittest" that? The Nim compiler uses integretation tests, not unit tests. Not too mention that the tester supports testing the different backends, runs tests in

Re: questions on proposal to default initializing string, seq to empty ("", @[]) instead of `nil`

2018-07-31 Thread Araq
Yes, these two statements will be identical.

Re: questions on proposal to default initializing string, seq to empty ("", @[]) instead of `nil`

2018-07-31 Thread Araq
The `nil` memory address will mean `""/@[]` but cannot be written as `nil` in Nim, it's just an implementation detail in order to not allocate these. Q2: yes.

Re: Generating pascal interface

2018-08-01 Thread Araq
I have used Nim's macro system to generate Squeak source code but the easiest route might be to use the compiler as a library and adapt `compiler/renderer.nim` to produce Pascal code.

Re: Next release? (re: bioconda)

2018-08-03 Thread Araq
0.19 is overdue but there are still hard to fix regressions left. If 0.19 doesn't make it this month, we will backport the most pressing problems to 0.18.2. :-/

Re: Winim - Nim's Windows API and COM Library

2017-01-17 Thread Araq
Very nice but I think it should adhere to style guide.

Re: Wrapping cpp type with integer parameters

2017-10-26 Thread Araq
Can't think of a solution except patching the compiler.

Re: db_mysql & threads

2018-03-17 Thread Araq
Doesn't this mean that you have to use multiple connections? Which seems easy enough to do.

Re: [RFC] Cyclic imports and symbol dependencies

2018-02-28 Thread Araq
> I guess the lack of reply on the actual RFC means it's not happening, or > maybe it ran into some kind of roadblock? Any proposal which cannot deal with macros is hard to accept. There seems to be an overlap between the people who like cyclic imports and those who use OO designs with

Re: Macros and imports

2017-01-01 Thread Araq
Use `macros.bindSym` for clean symbol bindings. Happy New Year!

Re: Any method to set backend by configuration or nim code?

2017-08-06 Thread Araq
Interestingly, you cannot do that for now. All you can do is to do something like when not defined(cpp): {.error: "compile via the 'cpp' command".}

Re: FSMonitor

2017-09-11 Thread Araq
`fsmonitor` is still in `lib/packages` so add that to your `--path`, this is not machine specific (but maybe your config is). fsmonitor is Linux specific and that's why it shouldn't be in the standard library.

Re: Command-line Parsing Preferences

2018-03-02 Thread Araq
> To me this kind of optional symbol table seems both backward compatible and > forward looking and strikes a good balance for a stdlib. I have to admit, this is quite convincing. Especially since it's just an addition to parseopt, breaking nothing, I hope.

Re: NIM compiler looses track of sub-processes on Linux

2017-05-09 Thread Araq
Ok, well, I have never seen that happen/reported before.

Re: Set of enums -- some caution is needed

2017-09-14 Thread Araq
Possible. The compiler dislikes enums that try to outsmart/override its chosen native representation.

Re: What can Nim learn from Crystal

2017-08-06 Thread Araq
My current plans for `method` are: * Change the semantics slightly: Only the first argument is considered in the dynamic lookups. Nothing else will change really. The only problem with that is that then we have 3 ways to do dynamic binding: 1. via closures. 2. via proc type fields with

Re: More control over allocations

2016-07-05 Thread Araq
> _It might be trivial with userland iterators, but they are difficult to > implement without concepts._ Maybe, I dunno. The real problem seems to be that functional programming simply doesn't work for performance. You always end up transforming the return type `T` to a `var T` parameter and

Re: how to find symbol definition on cmd line? can nimsuggest help?

2018-04-06 Thread Araq
Nimsuggest is documented here: [https://nim-lang.org/docs/nimsuggest.html](https://nim-lang.org/docs/nimsuggest.html) Unfortuantely it still lacks examples, PRs are welcome.

Re: Send data structures between threads?

2016-08-25 Thread Araq
> How do I avoid accidentally trashing the refcounts? protect and dispose only give you a `pointer` that you can cast to `ptr JsonObj` and so RCs are not affected. > But as you mentioned before, I can force it with a cast. Is that part of the > solution you're suggesting? Well yes. But you

Re: Perfecting Nim

2018-04-25 Thread Araq
> has the idea of openArray being a concept been considered? It seems to make > sense - an array has a set of properties that concept describes well: > indexable, len, etc Certainly, but I want to keep `openArray` and turn into borrowed array slices. The borrowing aspect is hard to achieve

Re: How to understand pragmas in Nim?

2017-01-24 Thread Araq
> For instance, why introduce {.pure.} with enums to require full > qualification? If the compiler does not respect the pragma, there are syntax > errors in the code. Typing and naming should be enough to avoid enums names > clashes. Wouldn't work with Nim's disambiguation rules. Think of enum

Re: Mascot

2017-03-20 Thread Araq
I'd rather have a new website today than a new website with a nice mascot tomorrow. So please help dom96 in finishing the website.

Re: Compositional inheritance voodo

2017-09-05 Thread Araq
It seems to be valid Nim code. It's also a design right from the 90ies, slow, impossible to parallelize, hard to serialize.

Re: var param vs tuple as return value

2017-01-25 Thread Araq
'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: Are closures supported?

2017-03-14 Thread Araq
Thanks. Fixed, this note is not relevant anymore, Nim has closures.

Re: testing private methods in external module

2017-10-25 Thread Araq
import macros macro tpub*(x: untyped): untyped = ## Marks a proc with an export asterisk when ``-d:testing`` is defined. expectKind(x, RoutineNodes) when defined(testing): let n = name(x) x.name = newTree(nnkPostfix, ident"*", n) result = x

Re: Nim Backend Support Plans? JS Backend Sample

2018-01-10 Thread Araq
Well bugs are bugs and only critical bugs are scheduled to be fixed before v1. The JS backend is not special in this regard, it's widely used and quite stable too. [https://github.com/nim-lang/Nim/issues/4470](https://github.com/nim-lang/Nim/issues/4470) seems to be the worst offender here.

Re: algorithm.sort() seems broken

2017-03-12 Thread Araq
Well without the test data that `sort` fails on, there is little I can do.

Re: Strange GC problem ?

2016-08-24 Thread Araq
https://github.com/nim-lang/Nim/issues/4653

Re: Maybe a bug about built-in string to cstring converter

2017-01-07 Thread Araq
The problem is that a `nil` check can always be inserted manually, but it's harder to get rid of it when the compiler emits it. Conversions to `cstring` should be as fast as possible and code size should be small.

Version 0.17.0 released!

2017-05-18 Thread Araq
It's one of those days ... [https://nim-lang.org/blog/2017/05/17/version-0170-released.html](https://nim-lang.org/blog/2017/05/17/version-0170-released.html) Enjoy! (Yes, all the concepts enhancements made it into this release!)

Re: Problem compiling nim with gcc in linux.

2018-03-16 Thread Araq
The full output of `sh build.sh && bin/nim c koch && ./koch tools` would be useful.

Re: module name collision across nimble packages

2018-04-03 Thread Araq
I don't like the dots and think we should deprecate them.

Re: var param vs tuple as return value

2017-01-28 Thread Araq
> I was not off-topic. This thread got pivoted to discussion of preferred > communication methods by Araq himself before I got here. Oh yeah and I regretted this remark... It's fine to ask newbie questions here, the forum will get a section for this. Now consider this thread **

Re: How is the compiler so clever, and how clever does it get?

2018-02-28 Thread Araq
Well the "compilation cache" / "symbol files" / "incremental recompilation" feature is in the works and indeed it treats `slurp` like `include` and so will notice if the dependency changed or not. But this feature is not yet ready for anything. Regardless of it, macros are always re-evaluated

Re: experimenting with pointers and slices

2017-12-03 Thread Araq
Seqs own the data they contain, views don't, conceptually there is no safe way to create a seq from a view without a copy. You can pass zero-copy slices in a `parallel` statement

Re: Custom memory allocator and memory region

2017-09-09 Thread Araq
`--gc:regions` will let you do that and is not far away, maybe a couple of weeks...

Re: Access procedure arguments from a macro when the procedure is called

2016-11-08 Thread Araq
Your solution is just fine once you replace `quote do:` by a dirty template+getAst (the preferred way to construct ASTs these days).

Re: Convert tuple into a Object

2017-09-02 Thread Araq
> I got tired of creating reference using the PIMPL or the following pattern var s:ref Person new(s) s.age ... Er, I think you use Nim wrong, (ref) object construction can be done like this: var s = (ref Person)(age: 3, name: "Burns") No tuples, no

Re: How to export data to C

2017-05-29 Thread Araq
This is not supported via `exportc`, but you can also use a `.codegenDecl` annotation to achieve it, no need for `.emit`.

Re: Code page 65001

2016-10-18 Thread Araq
Yeah, that change needs to be reverted, I got other reports about this problem.

Re: What do you think about Redox and Electron?

2017-01-09 Thread Araq
Redox looks impressive and while it would be nice for us if it were written in Nim, it's high time people stop writing C code. It's a nice project. Too bad it implements a Unix which means a **stringly typed** programming environment, defective shell scripting languages, tons of red tape,

Re: Concept[T] design question

2016-08-04 Thread Araq
Yes, you are needed, it's not overkill when 2 people work on the most wanted feature for Nim. :) 1. Agreed, I like this better too. 2. Dunno, will tell you when I review your code. 3. Agreed and `default(T)` at least is useful on its own. 4. Dunno. Btw neither yours nor Zahary's work

Re: Some questions regarding the practice of wrapping javascript libraries

2018-01-15 Thread Araq
`importcpp` works just fine with generics, every generic instantiation is then imported in the same way.

Re: Alternative comment syntax

2017-03-30 Thread Araq
Stop wasting everyone's time. Consider this thread closed.

Re: Status of Concepts

2016-07-08 Thread Araq
Status of concepts: * The documentation is outdated. * "Generic concepts" (Foo[T] = concept) don't work. * Symbol lookup rules in concepts need to be refined. * Unlikely to become stable for v1.

Re: book delayed again

2017-04-26 Thread Araq
> You will be forced to moderate posts like this soon. But I did moderate. I guess I should censor the next time.

Re: Compiler crash when pointers to generics from template

2018-03-11 Thread Araq
Compiler bug aside, you need to instantiate the procs, like `@[presentModeA[string], presentModeB[string]]`.

Re: Code page 65001

2016-10-25 Thread Araq
Not strange, MingW uses the libc that ships with Windows since Win95 days whereas VCC keeps updating its libc. It's actually a feature of MingW so that the executables have no external deps. Hard to fix these issues except perhaps getting rid of libc altogether (there are some Nim development

Re: Nim syntax Quiz

2018-03-14 Thread Araq
> Quiz 2: Now, imagine that you are a nim newbie. Try to fix the errors with > the help of nim manual and compiler error messages. Or,better yet, ask a nim > beginner to fix the code and watch the frustration grow. Or better yet, you ask a beginner who can read a tutorial again to look at some

Re: Seq with custom fields

2017-01-05 Thread Araq
Cross module inline procs are inlined across modules without link time optimization, the Nim compiler duplicates the inline procs in the generated C code.

Re: Enum related error: duplicate case value

2016-06-30 Thread Araq
It needs to be documented, c2nim generates it, so it's "officially" a part of Nim.

Re: How do I wrap this?

2017-07-15 Thread Araq
Untested idea: template cppDefinedMacro(def, body: untyped) = {.emit: "CPP_DEFINED_MACRO(", def, ") {", body, "}".} cppDefinedMacro "yay": cpp_defined_function(param1) other_cpp_defined_function(param2, param3)

string literals should not allocate; should allocate in ROM an extra `\0`

2018-07-19 Thread Araq
Ok, you're willing to pay the "penalty". I am not. > Fully sliceable strings and arrays are always better. The terminating zero doesn't preclude slicing (you can have a flag that indicates whether the terminator exists) but slicing has inherent ownership problems that the more convoluted

Re: Float should be 32 bit, 2x performance just by changing the defaults

2017-07-06 Thread Araq
1. When I said "we need to do something about it", I had something in mind like `12f` instead of `12'f32` which is what we have now for several versions. 2. Most of `math.nim` supports both floats and doubles. 3. `Vector3d` etc need to be made generic, no language change required. That

Re: Can't install nim on Win 8.1

2017-05-16 Thread Araq
Maybe you don't have a user level PATH environment variable then?

Re: floating point output formating

2017-11-08 Thread Araq
> It seems Araq doesn't really like my way of thinking. I can also see how Araq > reacted to pointing out formatFloat's odd behaviour for 0 (which was quite > odd to me, too). I, for instance, didn't notice it myself as I don't really > use Nim for numerical calculations (I use For

Re: Collaborative Documentation discussion and updates

2016-09-13 Thread Araq
* I would discuss it on this forum, but if you're keen on having a "threaded" discussion, we can also try reddit. * In my experience if you're looking for collaboration, IRC or Gitter work much better. You may not need real-time, but it helps. ;) Just compare how long it took me to reply

Re: HomeBrew + Nim Tools (nimble, nimsuggest)

2016-10-24 Thread Araq
We use `koch xz` to build the tarballs which does populate "dist": proc xz(args: string) = bundleNimbleSrc() bundleNimsuggest(false) ...

Re: How can I prevent function name abiguity

2017-03-15 Thread Araq
Use this: `sequtils.toSeq` to prevent the compiler from trying to use nre's version of it. Oh and don't use nre.

Re: Performance Comparison to C in Nested Loops

2016-12-09 Thread Araq
If you are on a 64 bit machine, Nim's `int` is 64 bits, C's is 32 bits. Use `int32` for a fair comparison. Seems unlikely to be the cause of the slowdown, but you never know. Definitely an interesting difference to look into. (Factor of 3-4 wtf...)

Re: What's happening with destructors?

2017-10-18 Thread Araq
The implementation and the spec are developed together and I don't want to say more until I'm sure it's not embarrassingly wrong. But things are starting to look really good, expect a blog post about this in a couple of days.

Re: Reason for -fno-strict-aliasing?

2017-08-24 Thread Araq
Well the C standard solution nowadays is that the cast must go through a union type and the code generator already can do that. PRs are welcome.

Re: Send data structures between threads?

2016-08-28 Thread Araq
> So what do you do: do you tell these teams not to use refs? Or do you tell > them to go ahead and use refs and garbage collection, and deal with the > consequences? To be honest I would fire teams who model business taxonomies with C++ classes (OMG), keeping all the data in RAM (OMG) and not

Re: what does macros.quote() do exactly?

2017-10-18 Thread Araq
`expandMacros` with its conversion to `typed` is really fragile with today's compiler. Instead use this to see what's going on: import future import macros macro decDumbType(): untyped = result = macros.quote do: type Dumb = ref object of RootObj

Re: How to create, destroy, and recreate threads

2017-04-03 Thread Araq
Sorry, I couldn't test this program, but I fixed the memory allocator and hopefully this bug disappears now. Please retry with devel.

Re: Partial code upgrades: important or meh?

2018-03-29 Thread Araq
Please, focus on Nimble lockfiles. > Nimble (and Nim itself for that matter) don't support a dependency on two > different versions of the same package. Is this a problem that will bite us > in the future? No, IMO it's a very reasonable limitation.

Re: Code page 65001

2016-10-25 Thread Araq
Interesting observation (and worth a github issue!), but as far as I'm concerned that `fwrite` is correct and `fputs` must not do any encoding conversions either. Either set the codepage to UTF-8 or use Nim's `encodings` module.

Re: Love nim but at the same time starting to hate it...

2016-07-07 Thread Araq
Looking at [https://docs.python.org/3/library/string.html](https://docs.python.org/3/library/string.html) I don't see too many things wrong with Nim's documentation. Yes you can ignore stuff in `{. .}` (and we should hide it). On the other hand, at least every parameter has its type listed

Re: [RFC] use `when predef.os.macosx` instead of `when defined(macosx)` ; more robust and scalable

2018-04-04 Thread Araq
Lol, please don't. I'm tired of nano improvements that make me touch thousands of lines of code. We need to ship what we have and call it a day. I don't remember mistyping these names all too often. And for other defines you can do: when defined(foo): const useFoo = true

Re: Nim improvement process

2016-08-10 Thread Araq
Regarding the development process: Forum posts like yours are perfectly acceptable to start a discussion but then the results should be extracted into a "Nim enhancement proposal" (NEP) that are for new kept on the github wiki. (We only have NEP-1 so far, the Nim style guide.)

Re: asyncdispatch and "closing server socket"

2018-02-05 Thread Araq
In your snippet you don't have to split up this in 2 different procs. And even if you do, you can pass `server` as a parameter. > And, more generally, does that mean I still need to use shared-heap to pass > messages/signals across async tasks? I think you can also use (async) queues instead.

Re: c2nim (forked from Partial casing is foo_bar)

2016-07-21 Thread Araq
> Why can't someone else do it? Fair enough, somebody else can do it. My work is then only to review the patch. The problem is though, that on top of the "it's work for me" argument, I don't want the feature. I don't see the point. The conflicts that do arise are all about ALLCAPS and I don't

Re: GTK 3.20 Nim wrapper

2016-07-10 Thread Araq
Cool, I will try it out! what would it take to merge this project with Aporia?

Re: Plans regarding named tuples

2017-02-27 Thread Araq
Well `object` is the obvious replacement, but this indeed does not cover all the use cases of named tuples. I like to remove named tuples to simplify the language. Maybe this means `object` needs to grow minor new capabilities. > I'm not sure if the DSL I'm designing would work without them.

Re: Deadlock using threadpool from a forked process.

2018-01-10 Thread Araq
Well? Anything we can do about that?

Re: Procedure which returns procedure

2017-03-31 Thread Araq
proc pprint(annotation: string): (proc(t0: T1): T1) = # ... some usage of annotation parameter .. Parenthesis help.

Re: An orientation document to the "mainstream" developer

2017-11-25 Thread Araq
Well I edited the document a bit but as soon as all the missing examples are added I don't see the advantage over the existing tutorials and introductions. I think it's better to focus on the advantages vs disadvantages aspect and not turn it into another tutorial. Advantages could include

Re: Linear algebra library

2017-06-09 Thread Araq
Well rewrite rules need to be able to target these `var result` operations (as I call them) so they need to exist anyway.

Re: Nim GC Performance

2016-12-05 Thread Araq
@jlp765 On what OS do you get that much jitter?

Re: Moving

2018-02-05 Thread Araq
var myPendingRequests {.threadvar.}: HashSet[ptr MsgBase] myPendingRequests.init() The compiler made you write this, it disallows `var myPendingRequests {.threadvar.} = initSet[ptr MsgBase]()`. Ever wondered why? Because it would only run for the main thread. I improved its error

Re: Perfecting Nim

2018-05-01 Thread Araq
> @[] and "" don't have to actually differ from nil, it could be an > implementation detail. Pretty much like option[ref T not nil] can be > implemented as ref T. Yep. And that's how it will be done.

Version 0.15 released!

2016-10-01 Thread Araq
We finally pulled the plug, new release has arrived. See [http://nim-lang.org/news/2016_09_30_version_0_15_0_released.html?ref=forum](http://forum.nim-lang.org///nim-lang.org/news/2016_09_30_version_0_15_0_released.html?ref=forum) for the details.

Re: What is

2018-03-05 Thread Araq
There are actually "filters" and "parsers" and "standard" means the standard indentation based syntax/parser. Which is also the default and so the `| standard` part can be left out.

Re: Maybe a bug about built-in string to cstring converter

2017-01-08 Thread Araq
Your WORST solution is what the C backend would have emitted.

Re: Compiler won't scale (still)

2018-03-17 Thread Araq
> Why not add a flag to set/disable the iteration limit like he wants? I'm sure > that as the user base grows, more people are going to hit the limit and get > annoyed. Because I am curious whether it can be supported out of the box by a "reasonable" limit first.

Re: Nim GC Performance

2016-12-06 Thread Araq
Well you can always switch it off and see what happens, "complex real world example" or not. You can also disable it selectively per thread or per time critical code part. you can also break up cycles manually via `ptr` and that's where Nim should be improving. Swift too embraces this model.

Re: Can I modify the AST of existing definitions?

2016-11-02 Thread Araq
No, that's not supported. You can implement it as a compiler plugin but you need to ensure that no codegen phase starts before your plugin did its transformation which is kind of hard to ensure with the current pipelined architecture in the compiler. It's also not a wise thing to attempt, it

Re: Statement macro applied on proc

2017-11-19 Thread Araq
Try instead macro duplicate(procStmt: untyped): untyped = ...

Re: Concept[T] design question

2016-07-21 Thread Araq
Let's go through your examples now. type StrangeConcept[T] = concept c c is T # Equivalent to "c is any", which is true float(c) is T # Equivalent to "float(c) is any", which is true $c is T # Equivalent to "$c is any", which is true when int is StrangeConcept:

Re: Too many global variables in a generated js-code

2017-09-15 Thread Araq
Yeah ok, you can only compile a single Nim program to JS. But that program can consist of as many Nim modules as necessary.

Re: pow and `^` and soon (?) `**`?

2016-10-18 Thread Araq
It always was the plan to use `^` and only `^` for exponentiation, so please go ahead with your PR. :)

Re: Fatal compilation error on Windows

2018-02-16 Thread Araq
Can you please keep us up-to-date about your game?

Re: Linear algebra library

2017-06-09 Thread Araq
In fact, this problem is so severe (every proc returning a string is affected) I thought about more language support for it: Every routine `foo(result: var T; args)` can be used as an expression of type `T` via the transformation into `(var res = default(T); foo(res, args); res)`

Re: SharedTable: missing hasKey() and len()

2017-12-03 Thread Araq
You have your own `withLock` implementation that the instantiation of `mget` prefers which introduces a new scope and so `hasKey` is outside of the scope. Probably sharedtables should be changed so that `withLock` is not used as a mixin. In the meantime, name yours `withL` and it compiles if

Re: Macros with head and body

2017-01-20 Thread Araq
Works just fine: import macros macro model(name: string; body: untyped): untyped = echo treeRepr body model "Person": field Name(string): max_length = 128 field Age(int): unsigned validate Age > 20 The only thing you

  1   2   3   4   5   6   7   8   9   10   >