Re: About include

2020-04-29 Thread Araq
I still encourage you to look into Nim's macro system which often is _easier_ 
since you operate on a different level.


Re: Nim sets compatibility/conversion to C

2020-04-29 Thread b3liever
another way I overlooked is some macro that converts Nim sets to C using if 
stmts, for example


var flip: set[RendererFlip]
var result: cint = 0
if FlipHorizontal in flip:
  result = result or 1
if FlipVertical in flip:
  result = result or 2


Run


Re: Embedding OpenGL window into some of our gui frameworks

2020-04-29 Thread enthus1ast
Also have a look at the sfml bindings. Sfml draws with gl.


Re: Termcurs

2020-04-29 Thread enthus1ast
I would add a description what your library is all about.

I just skimmed it and I saw vte. Ok I know that vte is the gnome terminal 
emulator but what is your project doing with terminal?


Re: NOOB: Is there a way to do: dos.com + my.nim ==> my.exe (Just ONE file)

2020-04-29 Thread enthus1ast
Another way would be to port a RunPe to nim and run it directly from memory.


Re: Termcurs

2020-04-29 Thread spip
Et vous pouvez éventuellement écrire cette description en français. Il y a 
suffisamment de francophones pour vous en proposer une traduction.


Re: Nim sets compatibility/conversion to C

2020-04-29 Thread shashlick
Try using nimterop which renders C enums as distinct cint.

Also check out @jyapayne's work on wrapping SDL2 with nimterop - 
[https://github.com/jyapayne/nim-sdl2](https://github.com/jyapayne/nim-sdl2). 


Re: Termcurs

2020-04-29 Thread enthus1ast
please speak english so that we all can participate


Re: Termcurs

2020-04-29 Thread JPLRouge
bonjour, il s'agit de retourver l'apparence du 5250/3270 un type de terminal il 
fonctionne sur le principe de fenêtre dans lequel on peut mettre des labels et 
fields button(f1...f24 et plus) leurs positionnements des relatif la gestion 
est automatisé: des fields leurs contenus / buttons de la même manière qu'un 
exfmt (ioPanel) fait sur OS400

l'exemple fourni explique bien les choses et ce que l'on peut en faire il y a 
beaucoup de chose prise en charge : ps j'ai vraiment appliqué à partir de livre 
que j'ai en ma possession d'IBM des fondements qui date de 1980, des principes 
en simplifiant et nim me le permettait.

Quand à SFLINE c'est un principe / il permet d'afficher un peu comme le 
scrolling mais beaucoup plus puissant. je suis actuellement sur le projet dans 
sfline pour proposé une solution simple et surtout viable

j'ai mis des images dans github de ce qui fonctionne. un exemple déjà pret.

Ps TermVte qui lui se base sur la lib vte3 on peut directement se servir de 
TermKey et TermCurs dans n'importe quel terminal Linux,

le terminal VTE pour l'avoir testé il est possible d'ajouter des fonctions par 
exemple: en C/C++ je gère les touches de clavier et il y a une communication 
interconnectée system (sys/msg.h) on peut aller très loin comme çà.

j'ai juste voulu mettre à disposition un terminal , après on peut l'améliorer...

le programme Termkey lui ignore TermVte il s'utilise comme une lib qui met a 
disposition une lecture du clavier respectant les normes Linux. n'a aucune 
dépendance hormis NIM-LANG

Mon traducteur est Google et faire traduire un concept n'est pas évident pour 
moi. je lis et comprends en général l'anglais sans rentrer dans la philosophie

je viens lire souvent sur le forum il y a de vrais pépite d'or et pour suivre 
l'évolution.

si quelqu'un pouvait traduire Merci


Re: Nim sets compatibility/conversion to C

2020-04-29 Thread b3liever
Thanks for sharing. So it works like 
[nim/sdl2](https://github.com/nim-lang/sdl2) and 
[Vladar/sdl2_nim](https://github.com/Vladar4/sdl2_nim)


type
  RendererFlags = distinct cint

const
  Renderer_Software* = 0x0001.RendererFlags
  Renderer_Accelerated* = 0x0002.RendererFlags
  Renderer_PresentVsync* = 0x0004.RendererFlags
  Renderer_TargetTexture* = 0x0008.RendererFlags

# has to borrow `or`?
let renderer = window.createRenderer(-1, Renderer_Accelerated or 
Renderer_PresentVsync)


Run

Though I would like a Nim api (and also port it to `--gc:arc` ), I will start 
with something minimal so I can continue with my game. 


Re: Termcurs

2020-04-29 Thread JPLRouge
he wants to help me explain and he will translate.


Re: Introducing --gc:arc

2020-04-29 Thread treeform
Is there a way to disable automatic tracing runs of --gc:orc and only run them 
when we want to -- say between rendering frames or loading levels? Is there a 
way to limit the time the tracing step runs?

You can pass --gc:arc refs between threads right? Which thread does --gc:orc 
run on?


Re: Introducing --gc:arc

2020-04-29 Thread adrianv
I recently had a problem with `sink` parameter inference in exported procs. I 
haven't looked how it is now, but I think that exported procs should never have 
inferred `sink` parameters, because nim can't be sure in that case. 


Re: Introducing --gc:arc

2020-04-29 Thread Araq
> Is there a way to disable automatic tracing runs of --gc:orc and only run 
> them when we want to -- say between rendering frames or loading levels? Is 
> there a way to limit the time the tracing step runs?

It's doable via the existing APIs `GC_disableMarkAndSweep` and 
`GC_enableMarkAndSweep`. There is no way to limit the tracing steps yet, but 
it'll use the existing "realtime" API.

> You can pass --gc:arc refs between threads right? Which thread does --gc:orc 
> tracing run on?

I'm afraid we have to ensure that only acyclic data is shared between threads. 
:-) 


Re: Termcurs

2020-04-29 Thread spip
_Here is the English translation of the French explanations that_ **JPLRouge** 
_gave. But even in French, the text was not really clear and I 'm not an expert 
of IBM VT terminals and libraries..._

Hello,

The goal is to revive the good old 5250/3270 dumb terminals. That type of 
terminal is based on windows where you can put labels and field buttons (F1 ... 
F24). Their relative placement on the window is automatic, in the same way as 
an exfmt (ioPanel) does on OS/400 (language RPGFILE).

The example presents what can be done. Many features are supported. They were 
done from books I have from IBM dating from 1980, as Nim was supporting it.

Regarding SFLINE, this feature is a bit like scrolling but more powerful. I'm 
presently working on implementing SFLINE with a simple and viable solution.

I've put screenshots on GitHub of what is working. There's also an example.

TermVTE is based on the library VTE3. But one can use TermKey and TermCurs 
directly on any Linux terminal.

Having tested VTE terminal, it is possible to add features. Using C/C++, I can 
manage the keyboard and there is a powerful interconnected system communication 
(sys/msg.h) that can be used.

I only wanted to release a terminal. There's place for improvement...

The TermKey program does not use TermVTE. It can be used as a library to read 
input from the keyboard while respecting Linux standards. There's no other 
dependance but Nim. 


Re: About include

2020-04-29 Thread spip
That's what I'm presently doing. I'm using the following pattern (presented 
top-down for easier reading):


template dsl*(bodyDsl: untyped) =
  # Structure of the DSL
  block:
# Inject context variables and do init...
template action(bodyAction: untyped) =
  # Here in action context.
actionImpl(bodyAction)
...

macro actionImpl(body: untyped): untyped =
  # Delegate syntax processing to procs
  ... extract pieces of syntax
  proc1(var1, code1)
  proc2(var2, code2)
  ...

proc proc1(var1: int; body: NimNode) =
  # Procs can mix different type of arguments and
  # easier to use in proc body.
  ...
  v = op(v1, v2)

template op(v1: Type1; v2: Type2) =
  # Optimize operators at the lowest level


Run

Using procs below the macro level means that I don't have to take care of 
`typed/untyped` arguments and automatic macro `untyped` conversions. And I use 
again templates at the lowest level, for small operations or optimizations. I 
hope this pattern will make sense and that the code will be easy to 
understand... 


Re: optional int parameters for a proc

2020-04-29 Thread mratsim
I really don't like converters if they are not in a "lenient_ops" kind of 
module.

They introduce hard to debug bugs where the original input is converted and 
then not matched to something or ambiguous call because you have 2 automatic 
conversion possible (for example uint16 to int or uint16 to "SomeInteger" at 
best (because caught at compile-time) to runtime error.

They can even cause symbol visibility issues if they are not exported + slow 
down compilation significantly (see 
[https://github.com/mratsim/Arraymancer/issues/394](https://github.com/mratsim/Arraymancer/issues/394))


Re: Error: unhandled exception: paramCount is not implemented on Nintendo Switch [OSError]

2020-04-29 Thread lotzz
If there is no quick fix, i guess i can patch the file. but i just thought id 
show this because it is weird


Error: unhandled exception: paramCount is not implemented on Nintendo Switch [OSError]

2020-04-29 Thread lotzz
I got this error msg from this code


#The file is get_saves.nims

import parseopt
import "check_installed.nims"
echo check_installed.exists
var ops = initOptParser()
while true:
  ops.next
  case ops.kind
  of cmdEnd: break
  of cmdLongOption, cmdShortOption:
echo "got and option"
  of cmdArgument:
echo "got and argument"


Run

Here is the other file "check_installed.nims"


from os import `/`
mode = ScriptMode.Verbose

var user_profile = getEnv("userprofile")
let minecraftDir = user_profile / "AppData/Roaming/.minecraft"
var exists* = false
if dirExists(minecraftDir):
  exists = true
  echo "The Java Edition of minecraft has been installed on this system"
  echo "We will now be creating a directory: .resourceManager in your 
UserProfile directory( " & user_profile & " )"
else:
  echo "The Java Edition of minecraft has not been installed on this system"
  echo "Exiting..."
  quit(0)


Run

This might be a little spammy, but I am just trying to make a simple script 
that checks if minecraft is installed, grabs my save folder and allows me to 
manage resource packs and datapacks from another area using a CLI.

This is the output I get from running "nim get_saves.nims"


{{USERNAME}}@{{COMPUTER_NAME}} ~/Documents/GitHub/CodeDump/minecraft 
(master) $ nim get_saves.nims
Hint: used config file 
'C:\Users\{{USERNAME}}\.choosenim\toolchains\nim-1.2.0\config\nim.cfg' [Conf]
The Java Edition of minecraft has been installed on this system
We will now be creating a directory: .resourceManager in your UserProfile 
directory( C:\Users\{{USERNAME}} )
true
stack trace: (most recent call last)
C:\Users\{{USERNAME}}\Documents\GitHub\CodeDump\minecraft\get_saves.nims(4, 
24)

C:\Users\{{USERNAME}}\.choosenim\toolchains\nim-1.2.0\lib\pure\parseopt.nim(229,
 49) initOptParser
C:\Users\{{USERNAME}}\.choosenim\toolchains\nim-1.2.0\lib\pure\os.nim(2693, 
5) paramCount
C:\Users\{{USERNAME}}\.choosenim\toolchains\nim-1.2.0\lib\pure\os.nim(2693, 
5) Error: unhandled exception: paramCount is not implemented on Nintendo Switch 
[OSError]


Run

I am on a Windows 10 OS and i wonder if this is some kind of bug


Re: Error: unhandled exception: paramCount is not implemented on Nintendo Switch [OSError]

2020-04-29 Thread Araq
Do you use Nim devel? Because if so, there is a regression in Nim devel that 
we'll fix before the next release.