single page applications that compile to webassembly

2018-10-12 Thread timothee
This was just announced, for D: 
[https://www.mail-archive.com/digitalmars-d-announce@puremagic.com/msg38951.html](https://www.mail-archive.com/digitalmars-d-announce@puremagic.com/msg38951.html)
 Spasm - webassembly libary for single page applications

  * [skoppe/spasm: Write single page applications in D that compile to 
webassembly]([https://github.com/skoppe/spasm](https://github.com/skoppe/spasm))



Maybe something worth exploring in Nim, to do nim=>wasm directly instead of 
nim=>js

  * produce more efficient code on the browser via wasm
  * (perhaps) avoid some limitations of js backend




Re: How to customize docgen css?

2018-10-12 Thread kaushalmodi
Unrelated to OP's question, but related to nimdoc:

I never got the JavaScript based search to work, even after copying dochack.js 
from Nim docs site. I see that's the case with the glob docs too.

I am looking for a solution to that. 


Re: How to customize docgen css?

2018-10-12 Thread citycide
I believe it should just be `nimdoc.cfg` without your project's name in there. 
I do it in 
[citycide/glob](https://github.com/citycide/glob/blob/a7ed90c8bd36613417ecc435ee76b58f50352503/nimdoc.cfg).


How to customize docgen css?

2018-10-12 Thread sflennik
How do you customize the html css output created by the nim rst2html command?

I was able to edit the compiler's config file 
(~/.choosenim/toolchains/nim-0.19.0/config/nimdoc.cfg) to customize the css and 
I saw the changes in the css output.

However, now I'm trying to do it with my own config file without touching the 
compiler config.

I put a myprojectnimdoc.cfg file next to my project's nimble file but this 
doesn't do anything. Here is the command I'm running:

nim rst2html --out:docs/main.html docs/main.rst

Here is the contents of the myprojectnimdoc.cfg file:



body {
 background-color: green;
}



Run


Re: converter capture

2018-10-12 Thread Araq
The only way is `import x except converterA, converterB, converterC, ...`

`import x except converter` would be cool. (But no, not another RFC please!)


Re: Need gzopen(filename, mode...) proc with similar behaviour to open(filename, mode...)

2018-10-12 Thread enormandeau
Thanks. I looked at nimarchive. I cannot see how this can be a simpler approach 
than using zip/gzipfiles and Streams.

Do you have sample code using nimarchive to read gzip files line by line?


Re: Need gzopen(filename, mode...) proc with similar behaviour to open(filename, mode...)

2018-10-12 Thread juancarlospaco
nimarchive ?.


syntax highlight of nims, nim.cfg, nimble files broken on github, highlight, sublimetext

2018-10-12 Thread timothee
## on github

  * nim files work
  * config.nims files don't syntax highlight at all:



[https://github.com/kaushalmodi/hello_musl/blob/master/config.nims](https://github.com/kaushalmodi/hello_musl/blob/master/config.nims)

IIUC, syntax highlighting on github is handled in 
[https://github.com/github/linguist](https://github.com/github/linguist) and 
yes they accept PR's

  * foo.nimble files don't syntax highlight at all:



[https://github.com/nim-lang/Nim/blob/devel/tests/deps/zip-0.2.1/zip.nimble](https://github.com/nim-lang/Nim/blob/devel/tests/deps/zip-0.2.1/zip.nimble)

  * nim.cfg seem ok:



[https://github.com/nim-lang/Nim/blob/devel/config/nim.cfg](https://github.com/nim-lang/Nim/blob/devel/config/nim.cfg)
 (nit: some constructs aren't highlighted, but ok)

## using highlight (brew install highlight; works on linux too)

  * nim files work
  * nimble files don't syntax highlight:



eg: tests/deps/zip-0.2.1/zip.nimble

  * nims files don't syntax highlight:



eg: tests/test_nimscript.nims

  * nim.cfg don't syntax highlight:



config/nim.cfg

## sublimetext (with NimLime)

  * nimble files don't syntax highlight



reported in 
[https://github.com/Varriount/NimLime/issues/108](https://github.com/Varriount/NimLime/issues/108)

  * works: nim, nims, nim.cfg




converter capture

2018-10-12 Thread geezer9
Are there any compiler options to get actual converter usage printed in nim 
compiler [Hint] output?

Or perhaps a pragma that prevents converter usage within some context.

Some modules have so many converters that it is hard to hell what one's own 
code is actually doing.

Especially converters that change a proc parameter x into its address.


Re: confused about new runnable code blocks `.. code-block:: :test:` (#9228) vs runnableExamples?

2018-10-12 Thread timothee
ping /cc @araq


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread kcvinu
If you ever installed python in your windows pc, the installer window has a 
checkbox with a text similar to this -- "Add python to PATH"


Need gzopen(filename, mode...) proc with similar behaviour to open(filename, mode...)

2018-10-12 Thread enormandeau
For some applications, it is needed to read large (10-100Go+) compressed files 
line by line.

Moreover, it is needed to be versatile in letting the program decide if a file 
is compressed or not (has ".gz" at the end) and decide whether to open it as a 
File or as a GZFile.

Specifically, being able to write the following function would be very useful 
and much easier than playing with streams:


proc myopen(filename: string, mode: FileMode=fmRead): File =
  # Look for ".gz" at the end of "filename"
  # to decide if a File or GZFile should be returned
  
  if filename[^3..^1] == ".gz":
return gzopen(filename)
  
  else:
return open(filename)


Run

The zip/gzipfiles module offers the possibility to create GZFileStream objects, 
but I'd argue that having to play with streams is making it harder on new NIM 
users than it could (should?) be.

Having GZFile objects (that behave like File) and gzopen proc (that behaves 
like open for files) would make it much easier to deal with this case.

I think this woud be very useful to a lot of data scientists attracted to NIM 
and these people, who already use Python a lot, are a bit pool of potential NIM 
enthusiasts.


Re: Read gzip-compressed file line by line

2018-10-12 Thread enormandeau
I did look at nim-hts a bit. I'll look some more for this _BGZ_ type as you 
suggest. Thanks!


Introducing Reel Valley

2018-10-12 Thread durandu
Is Reel Valley dead? I can't find it on Google Play.


Re: Opposite of astGenRepr

2018-10-12 Thread cdome
Try using getAst with **dirty** template instead of quote. They a similar in 
terms of the functionality, but getAst gives you more control


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread Araq
`finish.exe` can update the PATH just fine...


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread kaushalmodi
> But the problem is, i am expecting the program to do it automatically.

PATH is a user environment variable. I haven't seen any program installation 
modify that var. And that's a good thing.

I haven't used choosenim (as it doesn't work on my OS), but may be it should 
display something like "nim binary is installed at /foo/bar/bin/", and that the 
user should add that to their path themselves.

See how PATH update instructions are added to Go installation too. 


Re: `import foo {.private.}` to allows access to private fields (eg: package-level visibility)

2018-10-12 Thread LeuGim
I too think grouping modules is the right way, for the same reasons - private 
to stay private, not at the user's discretion. What _@Zahary_ suggests in 
[https://forum.nim-lang.org/t/4293](https://forum.nim-lang.org/t/4293).


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread LeuGim
Try to run choosenim as administrator, that may be the reason of not changing 
PATH.


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread kcvinu
In Win10 editing path is somewhat easy. But in older versions, its an annoying 
task. I know that when installing some programs, they will ask to add in PATH. 
So i am sure that a programmer can do this task via code. But why did some 
programmers not including this feature ? I know what a PATH is. But the problem 
is, i am expecting the program to do it automatically.


Re: It is not easy to find generic procs like system.find()

2018-10-12 Thread timothee
  * at first I thought this was a case like [[docgen] The search box is not 
working on certain symbols, eg: fmt · Issue #9198 · 
nim-lang/Nim]([https://github.com/nim-lang/Nim/issues/9198](https://github.com/nim-lang/Nim/issues/9198))
 however that's a different issue
  * looks like results are capped at the (slightly odd...) number of 19 
entries; would be good to allow configuring that perhaps in js




Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread Araq
Learn about the PATH environment variable and how to edit it.


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread kcvinu
Ha ha, Those comments raising a question in my mind, especially Araq's comment. 
He said 


Sorry, but I don't want sugar for this sharp knife. cast is the most 
dangerous feature of Nim, it's deliberately designed to be ugly.


Run

How do we do type casting without danger ?


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread kcvinu
Thanks for the example but i want to make a cast function for all data types, 
not only for the int. Int was just an example. Thats why i planned to write a 
template.


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread kcvinu
I have intalled choosenim but my CMD is not recognizing choosinm 


Re: Trying to learn templates, but its hard to understand.

2018-10-12 Thread kcvinu
I want to install nim 0.19 but i think either i did something wrong or 
something happened wrong. After installing choosenim, i have a folder in my pc 
like this-- 


C:\Users\Vinod\.choosenim\toolchains\nim-0.19.0


Run

But if i type "nim" in CMD, it seems that the version is still 0.18. Horribile. 


Re: How do i compile asm files with vcc compiler?

2018-10-12 Thread Araq
IIRC we patched the compiler to use `yasm` for this...


It is not easy to find generic procs like system.find()

2018-10-12 Thread Stefan_Salewski
Yesterday I missed a delete proc like the de() from this code:


proc de[T](s: var seq[T]; x: T) =
  let p = s.find(x)
  if p > 0:
delete(s, p)

proc main =
  var a = @["aa", "bb", "cc"]
  a.de("dd")
  echo a
  a.de("bb")
  echo a

main()


Run

That type of delete is available in Ruby, so one may hope for it in Nim -- well 
it is O(N), but maybe still OK for tiny seqs. On can easily guess that one has 
to use a combination of find() and delete() for that operation. But when we try 
to find find() proc from

[https://nim-lang.org/docs/lib.html](https://nim-lang.org/docs/lib.html)

and type in "find" it is not listed unfortunately, which is a bit confusing.