Re: Python transpiler

2020-07-14 Thread juancarlospaco
Ive read that parsing the .PYC is even easier, because some constructs are 
"expanded" there, like `:=` is a normal assign, `@decorator` is a normal 
function, and so on, I dont know if true tho. 


Re: Python transpiler

2020-07-13 Thread juancarlospaco
I created the repo because people were asking for **an Example** on how to do 
that, it is an example it was not meant to be complete.

...but if people are interested on making a real working one, we can team-up or 
whatever.

:) 


Re: Why does wrapping the code in a top level procedure make it faster?

2020-07-01 Thread juancarlospaco
Otherwise all variables are global. I dont know whats a cinoaiker. 


Connection-Pooling Compile-Time ORM

2020-06-29 Thread juancarlospaco
[https://juancarlospaco.github.io/nim-gatabase](https://juancarlospaco.github.io/nim-gatabase)

  * `0` Dependency, uses `system.nim` only, everything is done via `template` 
and `macro`, Docs, Examples, CI, etc etc (`db_postgres` for Postgres but 
Optional)
  * Running compile-time and JavaScript: 
[https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:13:49](https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:13:49)
  * Running static connection Array 100 Postgres: 
[https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:14:102](https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:14:102)



:)


Re: advanced `nim doc` use

2020-06-28 Thread juancarlospaco
`--docInternal` ?.


Re: NvP: s = s & 'x'

2020-06-24 Thread juancarlospaco
Use a `main()` for bench. 


Re: Help, I can't return an openarray

2020-06-23 Thread juancarlospaco
Return an array?.


Nim embedded inside Python

2020-06-21 Thread juancarlospaco
[https://github.com/juancarlospaco/nimscript4python#nimscript4python](https://github.com/juancarlospaco/nimscript4python#nimscript4python)

Done after the talk of Nim Conf 2020. 


Re: First take: parameters

2020-06-20 Thread juancarlospaco
Something like this? 
[https://github.com/Yardanico/nimpylib/blob/master/src/pylib/print.nim#L13](https://github.com/Yardanico/nimpylib/blob/master/src/pylib/print.nim#L13)


Re: First take: parameters

2020-06-20 Thread juancarlospaco
I dont understand what the problem is, if any. 


Re: Unclear (for Python people) import behavior. And how to deal with it

2020-06-18 Thread juancarlospaco
  * 
[imports](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Imports)
  * 
[Objects](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Objects)
  * [I recommend read it 
completely](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#table-of-contents)




Re: Perf: Table.del(key)is taking 85% of my code's time

2020-06-17 Thread juancarlospaco
`--opt:size` can me stuff slower, it changes file size for speed. 


Re: Nim's popularity

2020-06-15 Thread juancarlospaco
[https://tjpalmer.github.io/languish/#y=mean=nim%2Ccrystal%2Craku%2Chaxe%2Celm%2Cd%2Cwebassembly%2Cpurescript%2Cracket%2Cllvm%2Cpony%2Cred%2Cgdscript%2Cmathematica%2Cvisual+basic%2Cprocessing](https://tjpalmer.github.io/languish/#y=mean=nim%2Ccrystal%2Craku%2Chaxe%2Celm%2Cd%2Cwebassembly%2Cpurescript%2Cracket%2Cllvm%2Cpony%2Cred%2Cgdscript%2Cmathematica%2Cvisual+basic%2Cprocessing)


Re: No `[]` iterators for collections?

2020-06-10 Thread juancarlospaco
Theres no `x`.


Re: Automated Nim Packages Security Audit

2020-06-08 Thread juancarlospaco
**Help Wanted**

If you develop some kind of library that does Plotting, Charts, Visualizations, 
etc on Nim, would be nice to have some cool visualizations with the dataset of 
those audit logs!.

Theres lots of data now... :) 


Python PIP for Nim

2020-06-06 Thread juancarlospaco
`nimble_install` is 1 Python package that can install any Nim package directly 
from PIP, can be used from `requirements.txt` or command line terminal, it can 
install any number of packages by name separated by commas, no maintenance 
required, can install Nimpy from PIP, can install the Compiler from PIP, etc.

[https://github.com/juancarlospaco/nimble_install#use](https://github.com/juancarlospaco/nimble_install#use)

:) 


Re: Lambda syntax is awkward

2020-06-02 Thread juancarlospaco
Python lambda is single line only. :) 


Re: Lambda syntax is awkward

2020-06-02 Thread juancarlospaco
[https://github.com/Yardanico/nimpylib/blob/master/src/pylib.nim#L161](https://github.com/Yardanico/nimpylib/blob/master/src/pylib.nim#L161)


Re: What is -> in Nim?

2020-05-29 Thread juancarlospaco
[https://nim-lang.github.io/Nim/sugar.html#-%3E.m%2Cuntyped%2Cuntyped](https://nim-lang.github.io/Nim/sugar.html#-%3E.m%2Cuntyped%2Cuntyped)

Syntax sugar for a function, it is an arrow. 


Re: Nim Cheatsheet PDF (English+Spanish+Latex)

2020-05-28 Thread juancarlospaco
That was the idea, use it as template for more cheatsheets or other stuff. :)


Re: Nim Cheatsheet PDF (English+Spanish+Latex)

2020-05-28 Thread juancarlospaco
Fixed.

Maybe we need that overload (???) ;P 


Re: VSCode debug: strings and booleans are ugly

2020-05-28 Thread juancarlospaco
`assercho` is `assert` and `echo` combined, with extra Debug, it shows the Nim 
code line and the C code line, works with bool and string.

[https://github.com/juancarlospaco/nim-contra](https://github.com/juancarlospaco/nim-contra)


Nim Cheatsheet PDF (English+Spanish+Latex)

2020-05-27 Thread juancarlospaco
  * 
[https://www.overleaf.com/read/svnxffsjvscy](https://www.overleaf.com/read/svnxffsjvscy)




Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread juancarlospaco
... but walkPattern() does take a glob pattern. :) 


Re: Setting up a FreeBSD VM for Nim development

2020-05-22 Thread juancarlospaco
Would be nice to have this on the Wiki. :)


Re: Archived Nimble package

2020-05-19 Thread juancarlospaco
Create your own repo with fixes and updates and make a pull request on 
nim-lang/packages 


Re: A good word for idiomatic nim?

2020-05-12 Thread juancarlospaco
I read the 2 just Ok anyway. :P 


Re: Exporting json objects to Javascript, how can I make this code more terse?

2020-05-01 Thread juancarlospaco
Compile with `-d:danger` and put name on everything relevant with `{.exportc.}`.

Your code will probably go thru a Minifier anyways, so maybe better focus on 
tests and documentation.


Re: Typography update - now it can render 99% the Google Fonts ttf.

2020-04-30 Thread juancarlospaco
**Awesome!** , now it needs some kind of DSL to just write Latex-like syntax 
directly on Nim code, kinda like Rmarkdown but better.

:P 


Re: Automated Nim Packages Security Audit

2020-04-30 Thread juancarlospaco
I agree, a malicious actor can always just kick your door and hit you with a 
huge wrench. 


Re: Using existFile or existDir correctly.

2020-04-30 Thread juancarlospaco
You seem correct, if I understand the question. :)


Re: Understanding "Error: cannot evaluate at compile time"

2020-04-28 Thread juancarlospaco

type B[S: static[int]] = object
template foo(size: static[int]): auto = B[size]()
echo foo(16).repr

Run

Works on my machine 


Automated Nim Packages Security Audit

2020-04-25 Thread juancarlospaco
[https://github.com/juancarlospaco/nim_packages_security_audit#fully-automated-nim-packages-security-audit](https://github.com/juancarlospaco/nim_packages_security_audit#fully-automated-nim-packages-security-audit)

**Examples:**

  * 
[https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/z/zip.log](https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/z/zip.log)
  * 
[https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/s/sass.log](https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/s/sass.log)
  * 
[https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/w/webgui.log](https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/w/webgui.log)



More fresh data coming up everyday.

:) 


Re: NOOB: Few simple questions ...

2020-04-25 Thread juancarlospaco

import sugar
let seto = {1, 2, 3}
let seqo = sugar.collect(newSeq):
  for item in seto: $item
echo seqo

Run


let seto = {1, 2, 3}
let seqo2 = block:
  var lst: seq[string]
  for item in seto: lst.add($item)
  lst
echo seqo2

Run

Theres also `sequtils.toSeq`. Depending the use case it can be improved for 
sure.

On Nim "methods" are like free floating functions, I dont think is possible to 
list all of them, because you can create custom ones, and theres functions that 
can take `any` or `T`, return `auto`, etc.

If you want like an index to see which functions are on stdlib available, then 
CTRL+F on 
[https://nim-lang.github.io/Nim/theindex.html](https://nim-lang.github.io/Nim/theindex.html)


Re: Nim's strutils.split() slower than Python's string split()?

2020-04-24 Thread juancarlospaco
Compile with `-d:danger`. 


Re: Help understanding simple string pointer indexing example

2020-04-22 Thread juancarlospaco
I dont troubleshoot the code, but from a quick look, basically the pointer is 
empty uninitialized.

Kinda like doing `nil[1] = 'e'`


Re: How to return user defined type from a thread spawned?

2020-04-22 Thread juancarlospaco

import threadpool

type
  Person = ref object
name: string
age: int

proc worker(): Person =
  return Person(name: "john", age: 42)

proc main() =
  
  for i in 0 .. 10:
var t = spawn worker()
echo type(t)
  
  sync()

main()

Run

Prints `FlowVar[Person]`, I hope is what you needed...


Re: generate c++ code from .nim file

2020-04-16 Thread juancarlospaco
You can use a C++ code beautifier, like astyle, and skip the mangling with 
exportc pragma, but for reading only not for code thats actually used. 


Re: Compile-time string obfuscation

2020-04-16 Thread juancarlospaco
This cool code worth a package IMHO.


Re: String constant concatenation

2020-04-16 Thread juancarlospaco
This is a bug Python never fixed, because on Python it can implicitly 
concatenate different strings, like F-Strings, non-Unicode strings, Raw 
strings, ASCII strings, etc, often a crash at run-time is the result. 


New GUI Framework

2020-04-14 Thread juancarlospaco
New GUI Framework/toolkit/thingy:

  * 
[https://juancarlospaco.github.io/webgui](https://juancarlospaco.github.io/webgui)
  * 
[https://github.com/juancarlospaco/webgui/tree/master/examples](https://github.com/juancarlospaco/webgui/tree/master/examples)



Each push is built with --panics:on --gc:arc 


Re: Where can I deploy a Nim web application? Is there a "NimAnywhere" yet?

2020-04-13 Thread juancarlospaco
I think is kinda the reverse, Nim may run everywhere that can barely run C or 
JS. :)


Re: Web Scraping

2020-04-08 Thread juancarlospaco
[https://github.com/juancarlospaco/faster-than-requests#scraper](https://github.com/juancarlospaco/faster-than-requests#scraper)


Re: Nim programming book for kids

2020-04-07 Thread juancarlospaco
PDF Download would be cool. Awesome work!. :D 


Re: Custom default for type

2020-04-02 Thread juancarlospaco
[https://nim-lang.github.io/Nim/manual.html#implementation-specific-pragmas-codegendecl-pragma](https://nim-lang.github.io/Nim/manual.html#implementation-specific-pragmas-codegendecl-pragma)
 ?

Not sure if I understand the question tho.


Re: Nim Bugs

2020-04-02 Thread juancarlospaco
New version of nimbug with improvements from user feedback, feel free to give 
it a try. :)


Re: Nim 2, Nim 2020, and all that

2020-03-27 Thread juancarlospaco
Id say you can just check the `changelog.md` of `devel` today, to see whats 
coming up. :)


Re: {.this: self.} pragma

2020-03-24 Thread juancarlospaco
Std Lib `with` 
[https://nim-lang.github.io/Nim/with.html](https://nim-lang.github.io/Nim/with.html)


Nim Bugs

2020-03-24 Thread juancarlospaco
  * 
[https://github.com/juancarlospaco/nimbug#nimbug](https://github.com/juancarlospaco/nimbug#nimbug)
  * `nimble install nimbug`



Real life use case:

  * 
[https://github.com/nim-lang/Nim/issues/13722#issue-585682299](https://github.com/nim-lang/Nim/issues/13722#issue-585682299)




Re: Handling case in getSectionValue in parsecfg

2020-03-20 Thread juancarlospaco
`parseBool()`


Re: How to start a Jester server?

2020-03-18 Thread juancarlospaco
`nim c -r file.nim` _" Works on my machine"_ :)


Re: template expressions

2020-03-16 Thread juancarlospaco
Karax ?. 


Re: Documenting one liner

2020-03-05 Thread juancarlospaco

proc createMap(this:VS):ptr VSMap = this.vsapi.createMap()  ## \
  ## Creates a new property map. It must be deallocated later with 
freeMap().

Run

:) 


Re: Arraymancer and --gc:arc

2020-03-05 Thread juancarlospaco
Report the Bug maybe. 


Re: Some rant about nim

2020-03-03 Thread juancarlospaco

$ cat example.nim
type iX = range[1..5]

var a: iX = 3
var b = 10
a = b


$ nim c -r -d:release -d:danger --rangeChecks:on example.nim
Hint: 8022 LOC; 0.029 sec; 11.656MiB peakmem; Dangerous Release build; 
proj: Hint: /home/juan/code/temp1/example  [Exec]

fatal.nim(64)sysFatal
Error: unhandled exception: value out of range: 10 [RangeError]



Run


Re: Some rant about nim

2020-03-03 Thread juancarlospaco
It is _not_ a macro.

:) 


Re: Some rant about nim

2020-03-03 Thread juancarlospaco
That is literally an example on the documentation:

[https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates)


Re: Some rant about nim

2020-03-02 Thread juancarlospaco
Maybe with all that knowledge you can help improve things, send PR to whatever 
you think you can improve!.

:D


Re: How to declare a thread-global variable?

2020-03-02 Thread juancarlospaco
Try `--gc:go`. 


Re: How to declare a thread-global variable?

2020-03-02 Thread juancarlospaco
Boehm is not about ownership models.

Boehm was _not_ recently added nor removed.

`--gc:boehm` refers to 
[https://en.wikipedia.org/wiki/Boehm_garbage_collector](https://en.wikipedia.org/wiki/Boehm_garbage_collector)

On internet theres some articles saying is terribly slow in theory, but for 
some reason on Nim in actual usage is very fast, sometimes faster than Mark & 
Sweep.

Nim can do thread with boehm. 


Re: How to declare a thread-global variable?

2020-02-28 Thread juancarlospaco
Try `--gc:bohem`. 


Re: Doubt! Proc and import

2020-02-27 Thread juancarlospaco
Just put all import at top of file and should work. Nim is Compiled, all import 
are resolved at compile time. 


Re: Is this possible?

2020-02-27 Thread juancarlospaco

const some_module {.strdefine.} = "some_module"
template makeAnImport(module: static[string]): untyped = import module
makeAnImport(some_module)

Run

:)


Re: Templates and imports

2020-02-26 Thread juancarlospaco
[https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates)

Far from perfect, but better than nothing, Templates explanation. 


Re: How does nim infer that a cpu on windows is 64-bit

2020-02-26 Thread juancarlospaco
All PC hardware is 64Bit nowadays, since several decades ago, everything should 
be 64Bit. 


Re: Styling Karax app

2020-02-26 Thread juancarlospaco
[https://jenil.github.io/bulmaswatch](https://jenil.github.io/bulmaswatch)

Spectre is awesome but no themes. 


Re: Nim's float issue?

2020-02-25 Thread juancarlospaco
`round` is Deprecated. 


Re: func/proc blocks

2020-02-23 Thread juancarlospaco
imports can be an indented block.


Re: func/proc blocks

2020-02-22 Thread juancarlospaco
But you can have func inside func.


Nim new Playground/Pastebin of Spanish group

2020-02-20 Thread juancarlospaco
Hello!!, so we created a new web for our tiny Spanish-speaking community here, 
thats also a Pastebin, thats also a Playground, has some good features like 120 
Examples, machine code and AST of your code and others, we added QR Code SVG 
URLs recently too, feel free to visit, should not break too much on mobile but 
we dont have Designers, and sorry about the "Spanglish":

[http://argentina-ni.ml](http://argentina-ni.ml)

:) 


Re: How to package a nim program in an APK file

2020-02-20 Thread juancarlospaco
[https://github.com/akavel/hellomello#helloworldapk-built-with-nim-and-no-android-studio](https://github.com/akavel/hellomello#helloworldapk-built-with-nim-and-no-android-studio)


Re: soy nuevo en nim

2020-02-19 Thread juancarlospaco
Welcome!. Hay un grupo de [Chat Spanish](https://t.me/NimArgentina) , we also 
understand English. 


Re: Why whitespace?

2020-02-18 Thread juancarlospaco
I agree, but can be useful, imagine that you have a char exclusively for 
indentation, then code Minification and Prettify can be super simplified, and 
even maybe Parsing too. 


Re: Why whitespace?

2020-02-18 Thread juancarlospaco
True, but theres no dedicated Unicode codepoint for Indentation, then the most 
close is a generic space like the space character, would be interesting to have 
a Indentation dedicated Unicode codepoint, considering we got Poo  on Unicode. 


Re: Why whitespace?

2020-02-18 Thread juancarlospaco
Tabs are for Tabular Data by definition, source code is not Tabular Data. 


Re: Zig as C compiler for Nim. How to feed him the code

2020-02-18 Thread juancarlospaco
So does GCC. 


Re: Nim Compiling to js

2020-02-18 Thread juancarlospaco
[https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#table-of-contents](https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#table-of-contents)


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

2020-02-12 Thread juancarlospaco

  echo "hello", " ", "world"


Run

Or `writeLine(stdout, "hello", "world" )`


Re: Comparison Rust vs Nim binary sizes for IOT applications (just an FYI if you're interested)

2020-02-12 Thread juancarlospaco
If you want to strip the Nim binary a little bytes more, theres some strip 
options you can use, they are really long, but I contributed the improvements 
here on the "strip" task: 
[https://github.com/kaushalmodi/nim_config#list-available-tasks](https://github.com/kaushalmodi/nim_config#list-available-tasks)


Re: Suggestions for optimization?

2020-02-11 Thread juancarlospaco
const file = staticRead("dict.txt").strip.splitLines


Re: Parallel statement: procedure returning string

2020-02-06 Thread juancarlospaco
I am not sure I understand your code nor what you want to accomplish, but heres 
the same code returning string everywhere as you said:


import strutils, math, threadpool
{.experimental: "parallel".}

proc term(k: float): string =
  var f = 4 * math.pow(-1, k) / (2*k + 1)
  result = $f

proc pi(n: int): string =
  var ch = newSeq[string](n+1)
  parallel:
for k in 0..ch.high:
  ch[k] = ^ spawn term(float(k))
  result = ch.join

echo pi(5000)

Run

Just need to make the math make sense.

Flowvar is like a Promise on JavaScript or like a Future on Python, **but for 
parallel.** Like a container type thingy, to put other thingies inside, as they 
pop into existance at run time. 


Re: Extended routes that return json doesn't compile

2020-02-06 Thread juancarlospaco
Add `import json` everywhere and try again, the compiler will tell you if some 
import is not needed and then remove it. 


Re: Change server name in Jester

2020-02-06 Thread juancarlospaco
Adding a `{.strdefine.}` should not be that complicated. 樂 


Re: Can someone explain how to use the ".since" pragma?

2020-02-03 Thread juancarlospaco
[https://github.com/nim-lang/Nim/blob/92010becbe00b338abd4d9ef1be17739be8f69b8/lib/system/inclrtl.nim#L52](https://github.com/nim-lang/Nim/blob/92010becbe00b338abd4d9ef1be17739be8f69b8/lib/system/inclrtl.nim#L52)

It is just a `when` block. Similar to `when defined(release)`, but using the 
integers from the version number as conditional.


template since(version, body: untyped) {.dirty.} =
  when (NimMajor, NimMinor) >= version:
body

Run


Re: Template with dirty pragma within an async context

2020-02-02 Thread juancarlospaco
Change template to proc with async and inline ?. 


Re: Is "danger" define supposed to also define "release"?

2020-02-02 Thread juancarlospaco
Expected. (?)


Re: Help: Zip (Creating / Opening)

2020-02-01 Thread juancarlospaco
zip package from nimble. nimarchive package is also nice alternative. 


Re: Nim 1.0.6 is out!

2020-01-27 Thread juancarlospaco
`devel` is never published as an `stable` version by definition. 


Re: Nim macro help

2020-01-27 Thread juancarlospaco
`import macros`


Re: Code golfing in Nim

2020-01-26 Thread juancarlospaco
Person on Top of ranking should be emitting C++ or something... 樂


Re: conditional compilation from macro-generated code?

2020-01-25 Thread juancarlospaco
scope (?). 


Re: Fizzbuzz game

2020-01-25 Thread juancarlospaco
[https://github.com/code-golf/code-golf/issues/6#issue-259618460](https://github.com/code-golf/code-golf/issues/6#issue-259618460)
 & 
[https://github.com/code-golf/code-golf/issues/34#issue-322536856](https://github.com/code-golf/code-golf/issues/34#issue-322536856)


Re: Fizzbuzz game

2020-01-25 Thread juancarlospaco
[https://code-golf.io/scores/all-holes/nim](https://code-golf.io/scores/all-holes/nim)
 & [https://code-golf.io/fizz-buzz#nim](https://code-golf.io/fizz-buzz#nim)


Re: future of htmlgen

2020-01-23 Thread juancarlospaco
It is not removed. htmlgen added MathML, allows to use Latex on the web. 


Re: how can I use enum for collection of types

2020-01-23 Thread juancarlospaco

type Foo = int | bool

assert Foo(42) is Foo
assert Foo(true) is Foo


Run

Variant Type is probably what you are looking for.


Re: Naming conventions - need leading underscore

2020-01-16 Thread juancarlospaco
But Nim wont use underscore for private vs public. How underscores improve 
readability?.

`let __variable = 42` Vs `let variable = 42`. 


Re: Is this expected behaviour?

2020-01-14 Thread juancarlospaco
Start the Deprecation of `{.compileTime.}` ?. 


Re: How do you add switched to the build task?

2020-01-12 Thread juancarlospaco
switch("define", "ssl")


Re: Introducing --gc:arc

2019-12-27 Thread juancarlospaco
Remember to add it to the `changelog.md` and to 
[https://nim-lang.github.io/Nim/gc.html](https://nim-lang.github.io/Nim/gc.html)
 is an awesome work to not be mentioned. :) 


Re: understanding risk of shadowing

2019-12-22 Thread juancarlospaco
Nothing wrong with `n`.

All `proc` and `func` have an automatic `result` variable created from the type 
on the signature of the function.

Change `var result =` to `result =`


  1   2   3   4   >